2023-06-30 18:47:01 +00:00
|
|
|
#!/usr/bin/env nix-shell
|
|
|
|
#!nix-shell -i sh -p socat jq
|
|
|
|
|
|
|
|
ws_media="[08]"
|
|
|
|
ws_voip="[09]"
|
|
|
|
|
2023-07-06 21:38:19 +00:00
|
|
|
ws_media_at="[ 0, 0 ]"
|
|
|
|
|
2023-06-30 18:47:01 +00:00
|
|
|
_handler_check_ws_media_empty() {
|
|
|
|
|
2023-07-06 21:38:19 +00:00
|
|
|
# split at ">>" and get the second part and take first part of that
|
|
|
|
win_id=$(echo "$1" | cut -d'>' -f3 | cut -d',' -f1)
|
|
|
|
|
|
|
|
media_got_emptied="false"
|
|
|
|
|
|
|
|
is_on_media_ws=$(hyprctl clients -j | jq ".[] | select(.address == \"0x$win_id\") | .workspace.name == \"$ws_media\"")
|
|
|
|
if [ "$is_on_media_ws" == "true" ]; then
|
|
|
|
media_got_emptied="true"
|
|
|
|
fi
|
|
|
|
|
|
|
|
was_on_media_ws=$(hyprctl clients -j | jq ".[] | select(.address == \"0x$win_id\") | .at == $ws_media_at")
|
|
|
|
if [ "$was_on_media_ws" == "true" ]; then
|
|
|
|
media_got_emptied="true"
|
|
|
|
fi
|
|
|
|
|
|
|
|
has_zero_windows=$(hyprctl workspaces -j | jq ".[] | select(.name == \"$ws_media\") | .windows == 0")
|
2023-06-30 18:47:01 +00:00
|
|
|
if [ "$has_zero_windows" == "true" ]; then
|
2023-07-06 21:38:19 +00:00
|
|
|
media_got_emptied="true"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$media_got_emptied" == "true" ]; then
|
2023-06-30 18:47:01 +00:00
|
|
|
hyprctl dispatch workspace "$ws_voip"
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
handle() {
|
|
|
|
case $1 in
|
|
|
|
movewindow*) _handler_check_ws_media_empty "$1" ;;
|
|
|
|
closewindow*) _handler_check_ws_media_empty "$1" ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
socat -U - "UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" | while read -r line; do handle "$line"; done
|