You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dotfiles/bin/i3-focus.sh

16 lines
555 B
Bash

#!/usr/bin/env bash
# loops over i3 ipc events to prevent unnesecary polling
while :; do
# infinite loop
i3_msg=$(i3-msg -t SUBSCRIBE '[ "window" , "output" ]')
window=$(echo "$i3_msg" | gojq 'if .change == "focus" then .container.window_properties end | if .title == "tmux" then .title else .class end' | tr -d '"')
case "$window" in
'st-256color') echo 'st' ;;
'Brave-browser') echo 'Brave' ;;
'null') continue ;;
*) echo "$window" ;;
esac
done