scripts/sway/fullscreen-inhibitor.sh

12 lines
829 B
Bash
Executable File

#!/bin/sh
# Get all open windows from sway
IN_FULLSCREEN_NODES=$(swaymsg -t get_tree | jq '[paths(objects | select(.nodes)) as $p | getpath($p) | select((.window_properties.class) or (.app_id)) | {name: .name, app_id: .app_id, class: .window_properties.class, fullscreen_mode: .fullscreen_mode, focused: .focused}]' | jq 'any(.fullscreen_mode == 1)')
IN_FULLSCREEN_FLOATING_NODES=$(swaymsg -t get_tree | jq '[paths(objects | select(.floating_nodes)) as $p | getpath($p) | select((.window_properties.class) or (.app_id)) | {name: .name, app_id: .app_id, class: .window_properties.class, fullscreen_mode: .fullscreen_mode, focused: .focused}]' | jq 'any(.fullscreen_mode == 1)')
if [ $IN_FULLSCREEN_NODES = "true" ] || [ $IN_FULLSCREEN_FLOATING_NODES = "true" ]; then
dunstctl set-paused true
else
dunstctl set-paused false
fi