-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdynamic-borders.sh
executable file
·120 lines (107 loc) · 4.94 KB
/
dynamic-borders.sh
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/env bash
function handle {
if [[ ${1:0:10} == "openwindow" ]]
then
window_id=$(echo $1 | cut --delimiter ">" --fields=3 | cut --delimiter "," --fields=1)
workspace_id=$(echo $1 | cut --delimiter ">" --fields=3 | cut --delimiter "," --fields=2)
if [[ $workspace_id == "special" ]]
then
workspace_id=-99
fi
windows=$(hyprctl workspaces -j | jq ".[] | select(.id == $workspace_id) | .windows")
if [[ $windows -eq 1 ]]
then
floating_status=$(hyprctl clients -j | jq ".[] | select(.address == \"0x$window_id\" ) | .floating" )
if [[ $floating_status == "false" ]]
then
hyprctl dispatch setprop address:0x$window_id noborder 1
else
hyprctl dispatch setprop address:0x$window_id noborder 0
return
fi
elif [[ $windows -eq 2 ]]
then
addresses=$(hyprctl clients -j | jq -r --arg foo "$foo" ".[] | select(.workspace.id == $workspace_id) | .address")
for address in $addresses
do
if [[ "$address" != "$window_id" ]]; then
hyprctl dispatch setprop address:$(echo $address | xargs) noborder 0
fi
done
fi
elif [[ ${1:0:10} == "movewindow" ]]
then
window_id=$(echo $1 | cut --delimiter ">" --fields=3 | cut --delimiter "," --fields=1)
workspace_id=$(echo $1 | cut --delimiter ">" --fields=3 | cut --delimiter "," --fields=2)
# Sepcial workspaces have an id of -99, they need to be handled separately
if [[ $workspace_id == "special" ]]
then
workspace_id=-99
fi
windows=$(hyprctl workspaces -j | jq ".[] | select(.id == $workspace_id) | .windows")
if [[ $windows -eq 1 ]]
then
# Check if the current window is floating and then set the border accordingly
floating_status=$(hyprctl clients -j | jq ".[] | select(.address == \"0x$window_id\" ) | .floating" )
if [[ $floating_status == "false" ]]
then
hyprctl dispatch setprop address:0x$window_id noborder 1
else
hyprctl dispatch setprop address:0x$window_id noborder 0
return
fi
elif [[ $windows -eq 2 ]]
then
addresses=$(hyprctl clients -j | jq -r --arg foo "$foo" ".[] | select(.workspace.id == $workspace_id) | .address")
for address in $addresses
do
if [[ "$address" != "$window_id" ]]; then
hyprctl dispatch setprop address:$(echo $address | xargs) noborder 0
fi
done
fi
# Handle all the other workspaces with only one window
single_window_workspaces=$(hyprctl workspaces -j | jq '.[] | select(.windows == 1)' | jq ".id")
for workspace in $single_window_workspaces
do
window=$(hyprctl clients -j | jq ".[] | select(.workspace.id == $workspace) | .address")
hyprctl dispatch setprop address:$(echo $window | xargs) noborder 1
done
elif [[ ${1:0:11} == "closewindow" ]]
then
workspace_id=$(hyprctl activewindow -j | jq ".workspace.id")
windows=$(hyprctl workspaces -j | jq ".[] | select(.id == $workspace_id) | .windows")
if [[ $windows -eq 1 ]]
then
window_id=$(hyprctl activewindow -j | jq -r ".address")
floating_status=$(hyprctl activewindow -j | jq ".floating")
if [[ $floating_status == "false" ]]
then
hyprctl dispatch setprop address:$window_id noborder 1
else
hyprctl dispatch setprop address:$window_id noborder 0
return
fi
fi
elif [[ ${1:0:18} == "changefloatingmode" ]]
then
floating_status=$(echo $1 | cut --delimiter ">" --fields 3 | cut --delimiter "," --fields 2)
address="0x$(echo $1 | cut --delimiter ">" --fields 3 | cut --delimiter "," --fields 1)"
workspace_id=$(hyprctl clients -j | jq --arg address "$address" '.[] | select(.address == $address) | .workspace.id')
if [[ $floating_status -eq 1 ]]
then
hyprctl dispatch setprop address:$address noborder 0
else
no_windows=$(hyprctl workspaces -j | jq ".[] | select(.id == $workspace_id) | .windows")
if [[ $no_windows -eq 1 ]]
then
hyprctl dispatch setprop address:$address noborder 1
else
hyprctl dispatch setprop address:$address noborder 0
fi
fi
fi
}
# Socket directory has changed in Hyprland v0.40.0
# socat - UNIX-CONNECT:/tmp/hypr/$(echo $HYPRLAND_INSTANCE_SIGNATURE)/.socket2.sock | while read line; do handle $line; done
socat -U - UNIX-CONNECT:$(echo $XDG_RUNTIME_DIR)/hypr/$(echo $HYPRLAND_INSTANCE_SIGNATURE)/.socket2.sock | while read line; do handle $line; done