-
Notifications
You must be signed in to change notification settings - Fork 0
/
cleanfullscreen
executable file
·97 lines (84 loc) · 2.48 KB
/
cleanfullscreen
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/sh
# Clean fullscreen aims to provide a means to have a clean desktop when using
# transparency in bspwm, the issue I found was that when a window entered,
# fullscreen mode I was still able to see the windows behind it, I think this
# looks kind of gross so that's why this exists.
HideBar() {
polybar-msg cmd hide
}
ShowBar() {
polybar-msg cmd show
}
HideNodes() {
for node in $1; do
bspc node "$node" -g hidden=on
done
}
HideTiled() {
Nodes=$(bspc query -N -n .tiled -d "$1")
HideNodes "$Nodes"
}
ShowNodes() {
Nodes=$(bspc query -N -n .hidden -d "$1")
for node in $Nodes; do
bspc node "$node" -g hidden=off
done
}
bspc subscribe node_state | while read -r Event Monitor Desktop Node State Active
do
PrimaryMonitor=$(bspc query -M -m primary)
# Hide bar and nodes when node becomes fullscreen, otherwise show
if [ "$State" = "fullscreen" ] && [ "$Active" = "on" ]; then
# Only consider nodes on primary monitor
if [ "$PrimaryMonitor" = "$Monitor" ]; then
HideBar
fi
HideTiled "$Desktop"
else
if [ "$PrimaryMonitor" = "$Monitor" ]; then
ShowBar
fi
ShowNodes "$Desktop"
fi
done &
bspc subscribe node_remove | while read Event Monitor Desktop Node
do
PrimaryMonitor="$(bspc query -M -m primary)"
# Show bar if no nodes are fullscreen on current desktop
if [ "$Monitor" = "$PrimaryMonitor" ] && \
[ -z "$(bspc query -N -n .fullscreen -d "$Desktop")" ]; then
ShowBar
fi
ShowNodes "$Desktop"
done &
bspc subscribe node_transfer | while read -r Event SrcMonitor SrcDesktop SrcNode DestMonitor Dest Desktop DestNode
do
# Show nodes on src desktop and hide nodes on dest desktop
# If src node is in full screen mode
if [ -n "$(bspc query -N -n "$SrcNode".fullscreen)" ]; then
ShowNodes "$SrcDesktop"
HideTiled "$DestDesktop"
ShowBar
fi
# Hide any fullscreen nodes on destination desktop
FullscreenDest=$(bspc query -N -n .fullscreen -d "$DestDesktop" \
| sed "/$SrcNode/d")
if [ -n "$FullscreenDest" ]; then
HideNodes "$FullscreenDest"
fi
done &
bspc subscribe desktop_focus | while read -r Event Monitor Desktop
do
PrimaryMonitor="$(bspc query -M -m primary)"
FullscreenNode="$(bspc query -N -n .fullscreen -d "$Desktop")"
# Only consider nodes on primary monitor
if [ "$PrimaryMonitor" = "$Monitor" ]; then
# Hide bar if desktop contains fullscreen node
if [ -n "$FullscreenNode" ]; then
HideBar
# Otherwise show the bar
else
ShowBar
fi
fi
done &