aboutsummaryrefslogtreecommitdiff
path: root/.config/eww/scripts/bar-toggle.sh
blob: 8656687e8e760077670d743bd2a20b6964a4227d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash
monitors=$(river-bedload -print outputs | jq -r -c '.[] | .name' | wc -l | xargs)

for ((i = 0 ; i < $monitors ; i++)); do
	echo $i
	active_monitor=$(river-bedload -print outputs | jq 'map(.focused)|to_entries|.[]|select(.value)|.key')
	# Flip value e.g 0 to 1
	((active_monitor ^= 1))
	bar=$(eww active-windows | grep "bar$i")
	if [ "$active_monitor" == "$i" ] && [ "$bar" == "bar$i: bar$i" ]; then
		eww close bar$i
	elif [ "$active_monitor" == "$i" ]; then
		eww open bar$i
	fi
done