commit ac0269d

hovercats  ·  2024-09-06 03:09:41 +0000 UTC
parent 340906a
fullescreen: rewrite in rc
2 files changed,  +24, -47
+24, -0
 1@@ -0,0 +1,24 @@
 2+#!/bin/rc
 3+
 4+flag e +
 5+
 6+BW=2              # Border width
 7+ACTIVE=0xffffff   # Active border color
 8+FSFILE=/tmp/.fwin # Where values are stored
 9+
10+if (~ $#* 0) {
11+	printf 'Usage: fullscreen <wid>\n'
12+	exit 1
13+}
14+
15+test -f $FSFILE && wtp `{cat $FSFILE} && chwb -s $BW -c $ACTIVE `{pfw}
16+
17+if (test -f $FSFILE && grep -q $1 $FSFILE) rm -f $FSFILE
18+
19+if not {
20+    wattr xywhi $1 >$FSFILE
21+    chwb -s 0 $1
22+    wtp `{wattr xywh `{lsw -r}} $1
23+}
24+
25+focus $1
+0, -47
 1@@ -1,47 +0,0 @@
 2-#!/bin/sh
 3-#
 4-# z3bra - 2014 (c) wtfpl
 5-# toggle the fullscreen state of a window
 6-# depends on: focus
 7-
 8-set -e
 9-
10-BW="${BW:-2}"                    # border width
11-ACTIVE="${ACTIVE:-0xffffff}"     # active border color
12-
13-# this file is used to store the previous geometry of a window
14-FSFILE="${FSFILE:-/tmp/.fwin}"
15-
16-# it's pretty simple, but anyway...
17-usage() {
18-    printf "%susage: $(basename "$0") <wid>\n"
19-    exit 1
20-}
21-
22-# exit if no argument given
23-[ -z "$1" ] && usage
24-
25-# this will unset the fullscreen state of any fullscreen window if there is one.
26-# this way, there will only be one window in fullscreen at a time, and no window
27-# will loose their previous geometry info
28-# shellcheck disable=2046
29-[ -f "${FSFILE}" ] && wtp $(cat "${FSFILE}") && chwb -s "${BW}" -c "${ACTIVE}" "$(pfw)"
30-
31-# if file exist and contain our window id, it means that out window is in
32-# fullscreen mode
33-if [ -f "${FSFILE}" ] && grep -q "$1" "${FSFILE}"; then
34-    # if the window we removed was our window, delete the file, so we can
35-    # fullscreen it again later 
36-    rm -f "${FSFILE}"
37-
38-else
39-    # if not, then put the current window in fullscreen mode, after saving its
40-    # geometry and id to $FSFILE we also remove any border from this window.
41-    wattr xywhi "$1" > "${FSFILE}"
42-    chwb -s 0 "$1"
43-    # shellcheck disable=2046
44-    wtp $(wattr xywh $(lsw -r)) "$1"
45-fi
46-
47-# now focus the window, and put it in front
48-focus "$1"