ohmu
·
2026-07-25
1#!/bin/sh
2#
3# z3bra - 2014 (c) wtfpl
4# toggle the fullscreen state of a window
5# depends on: focus.sh
6
7# this file is used to store the previous geometry of a window
8FSFILE=${FSFILE:-~/.fwin}
9
10# it's pretty simple, but anyway...
11usage() {
12 echo "usage: $(basename $0) <wid>"
13 exit 1
14}
15
16# exit if no argument given
17test -z "$1" && usage
18
19# this will unset the fullscreen state of any fullscreen window if there is one.
20# this way, there will only be one window in fullscreen at a time, and no window
21# will loose their previous geometry info
22test -f $FSFILE && wtp $(cat $FSFILE)
23
24# if file exist and contain our window id, it means that out window is in
25# fullscreen mode
26if test -f $FSFILE && grep -q $1 $FSFILE; then
27 # if the window we removed was our window, delete the file, so we can
28 # fullscreen it again later
29 rm -f $FSFILE
30
31else
32 # if not, then put the current window in fullscreen mode, after saving its
33 # geometry and id to $FSFILE we also remove any border from this window.
34 wattr xywhi $1 > $FSFILE
35 chwb -s 0 $1
36 wtp $(wattr xywh `lsw -r`) $1
37fi
38
39# now focus the window, and put it in front, no matter which state we're in, and
40# put the cursor on its bottom-right corner (for consistency)
41focus.sh $1