summaryrefslogtreecommitdiff
path: root/files/sway/vrr_fullscreen.sh
diff options
context:
space:
mode:
Diffstat (limited to 'files/sway/vrr_fullscreen.sh')
-rwxr-xr-xfiles/sway/vrr_fullscreen.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/files/sway/vrr_fullscreen.sh b/files/sway/vrr_fullscreen.sh
new file mode 100755
index 0000000..0db4e10
--- /dev/null
+++ b/files/sway/vrr_fullscreen.sh
@@ -0,0 +1,29 @@
+#! /usr/bin/env bash
+
+# https://github.com/swaywm/sway/issues/5076#issuecomment-1753499364
+
+output_vrr_whitelist=("$(awk -F ' ' 'NR==1{print $3}' $HOME/.config/sway/monitors)")
+
+swaymsg -t subscribe -m '[ "window" ]' | while read window_json; do
+ app_id=$(echo ${window_json} | jq -r '.container.app_id')
+ if [[ $app_id == "com.moonlight_stream.Moonlight" || $app_id == "Waydroid" ]]; then
+ continue
+ fi
+ window_event=$(echo ${window_json} | jq -r '.change')
+ if [[ $window_event = "focus" || $window_event = "fullscreen_mode" ]]; then
+ output_json=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused == true)')
+ output_name=$(echo ${output_json} | jq -r '.name')
+ if [[ ${output_vrr_whitelist[*]} =~ ${output_name} ]]; then
+ output_vrr_status=$(echo ${output_json} | jq -r '.adaptive_sync_status')
+ window_fullscreen_status=$(echo ${window_json} | jq -r '.container.fullscreen_mode')
+ if [[ $output_vrr_status = "disabled" && $window_fullscreen_status = "1" ]]; then
+ swaymsg output "${output_name}" adaptive_sync 1
+ swaymsg 'seat * hide_cursor 0'
+ fi
+ if [[ $output_vrr_status = "enabled" && $window_fullscreen_status = "0" ]]; then
+ swaymsg output "${output_name}" adaptive_sync 0
+ swaymsg 'seat * hide_cursor 4000'
+ fi
+ fi
+ fi
+done