Skip to content

Instantly share code, notes, and snippets.

@2xsaiko
Created September 4, 2021 15:42
Show Gist options
  • Save 2xsaiko/d1b8a7741e63f6211081911904e48b32 to your computer and use it in GitHub Desktop.
Save 2xsaiko/d1b8a7741e63f6211081911904e48b32 to your computer and use it in GitHub Desktop.
swaywm: displays an [I] indicator in idle-inhibiting windows
#!/bin/bash
current=""
while true; do
new="$(swaymsg -t get_tree | jq -c 'recurse(.nodes[]) | del(.nodes) | select(.type == "con") | select(.inhibit_idle) | .id')"
for id in $new; do
re="\\b$id\\b"
if ! [[ "$current" =~ $re ]]; then
swaymsg "[con_id=$id] title_format \"[I] %title\""
fi
done
for id in $current; do
re="\\b$id\\b"
if ! [[ "$new" =~ $re ]]; then
swaymsg "[con_id=$id] title_format \"%title\""
fi
done
current="$new"
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment