commit 36de21f

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