master hovercats/bin / rc / fullscreen
 1#!/bin/rc
 2
 3flag e +
 4
 5BW=2              # Border width
 6ACTIVE=0xffffff   # Active border color
 7FSFILE=/tmp/.fwin # Where values are stored
 8
 9if (~ $#* 0) {
10	printf 'Usage: fullscreen <wid>\n'
11	exit 1
12}
13
14# move cursor to top left corner of window avoiding borders getting messed up
15wmp -a `{wattr xy `{pfw}}
16
17# unset fullscreen state if wid is in fullscreen
18test -f $FSFILE && wtp `{cat $FSFILE} && chwb -s $BW -c $ACTIVE `{pfw}
19
20# test if our wid is in $FSFILE, which means our window is in fullscreen state,
21# then remove the file so we can fullscreen later
22if (test -f $FSFILE && grep -q $1 $FSFILE) rm -f $FSFILE
23
24# put current window in fullscreen, and save needed data about it
25if not {
26    wattr xywhi $1 >$FSFILE        # Print offsets, dimentions and window id
27    chwb -s 0 $1                   # Remove borders
28    wtp `{wattr xywh `{lsw -r}} $1 # Teleport window into fullscreen
29}
30
31focus $1