aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/sway/.local/bin/sway-vrr
blob: e989ce972a94c5e4afb96c8ca4079945177f520d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh

swaymsg -t subscribe -m '[ "window" ]' |
	jq -c --unbuffered 'select(.change == "focus" or .change == "fullscreen_mode") | .container |
			if .fullscreen_mode == 1 then 
				{ "id": .id, "sync": "enabled", "rt": 1 }
			else 
				{ "id": .id, "sync": "disabled", "rt": 0 }
			end' |
	while read -r vals; do
		swaymsg -t get_tree | jq -r --argjson vals "$vals" --arg regex "$1" '.nodes[] | 
			select((.. | .nodes?[]?.nodes?[]?.id == $vals.id) and (.name | test($regex))) |
			if .adaptive_sync_status != $vals.sync then
				[ .name, "adaptive_sync", $vals.sync ] | @sh
			else
				empty
			end,
			if .max_render_time != $vals.rt then
				[ .name, "max_render_time", ($vals.rt | if . == 0 then "off" else . end) ] | @sh
			else
				empty
			end'
	done |
	xargs -l1 swaymsg output