26d17f8b75b4c5396a29024f774f28992f3f92d2
[distro-setup] / obs-i3-monitor
1 #!/bin/bash
2
3 set -e; . /usr/local/lib/bash-bear; set +e
4
5 try() {
6 "$@" || printf "warning: failed %s\n" "$*"
7 }
8
9 while true; do
10 while read -r line ; do
11 mark=$(printf "%s\n" "$line" | jq -r 'select (.change == "focus") | .container.marks[0]') ||:
12 if [[ $mark && $mark != null ]]; then
13 echo $mark > /tmp/last-obs-i3-mark
14 if [[ ! -e /tmp/no-obs-auto-scene-switch ]]; then
15 p=$(cat /p/obs-ws-pass)
16 try obs-cmd -w obsws://localhost:4455/$p scene switch $mark
17 fi
18 fi
19 # debugging
20 #printf "%s\n" "$line" | jq
21
22
23 # intentional process substitution to properly exit on kill
24 # ||: avoids error messages
25 done < <(i3-msg -t subscribe -m '[ "window" ]' ||:)
26 sleep 5
27 done