-
Notifications
You must be signed in to change notification settings - Fork 1
/
fsd
executable file
·78 lines (64 loc) · 1.48 KB
/
fsd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#! /bin/sh
# full screen to monitor
# usage: fsm <mon> <windowid>
usage () {
echo "usage: $(basename $0) <disp> <wid>"
exit 0
}
# Set the window given to full screen.
# usage: set_full <monitor> <window>
set_full () {
local monitor=$1
local window=$2
wattr xywhi $window >$tempfile
chwb -s 0 $window
wtp $(dattr $monitor) $window
wtf $window
chwso -r $window
}
# unsset the window given to full screen.
# usage: set_full <monitor> <window>
unset_full () {
wtp $(cat ${tempfile})
rm -f ${tempfile}
}
same_window() {
local stored_wid=$(cat $tempfile | cut -f5 -d' ')
[[ "$1" = "$stored_wid" ]] && return 0
return 1
}
#Did the window get resized another way?
check_moved() {
local window=$1
local recorded=$(cat $tempfile | cut -f '1-4' -d' ')
local current=$(wattr xywh $window)
if [ "$current" = "$recorded" ]; then
return 1
else
return 0
fi
}
display=$1
windowid=$2
tempfile="/tmp/fs_data_$display"
# All them checks.
test -z "$1" && test -z "$2" && usage
# check if display is valid
lsd | grep -q $display || usage
# check if windowid is valid
lsw | grep -q $windowid || usage
if [ -f $tempfile ]; then
if same_window $windowid; then
if check_moved $windowid; then
rm -f $tempfile
set_full $display $windowid
else
unset_full
fi
else
unset_full
set_full $display $windowid
fi
else
set_full $display $windowid
fi