From 7e1e8b59e4bd6e27b6244af41f24f12452acfa7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Eug=C3=AAnio?= Date: Fri, 14 Aug 2026 23:44:28 -0300 Subject: [PATCH] Revert "remove fullscreen only vrr" This reverts commit 1fcf1ecd5239783497f0d273a3904a16cf7aa15f. --- scripts/default.nix | 1 + scripts/vrr-fullscreen | 29 +++++++++++++++++++++++++++++ user/sway/default.nix | 15 +++++++++++++++ 3 files changed, 45 insertions(+) create mode 100755 scripts/vrr-fullscreen diff --git a/scripts/default.nix b/scripts/default.nix index 39fe853..b44b40a 100644 --- a/scripts/default.nix +++ b/scripts/default.nix @@ -159,6 +159,7 @@ print-battery-icon = [ ]; controller-battery = [ print-battery-icon ]; mouse-battery = [ print-battery-icon ]; + vrr-fullscreen = [ ]; nix-prefetch-firefox-extension = [ nix ]; diff --git a/scripts/vrr-fullscreen b/scripts/vrr-fullscreen new file mode 100755 index 0000000..faca977 --- /dev/null +++ b/scripts/vrr-fullscreen @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# List of supported outputs for VRR +output_vrr_whitelist=( + "DP-1" + "DP-2" + "DP-3" +) + +# Toggle VRR for fullscreened apps in prespecified displays to avoid stutters while in desktop +swaymsg -t subscribe -m '[ "window" ]' | while read window_json; do + window_event=$(echo ${window_json} | jq -r '.change') + + # Process only focus change and fullscreen toggle + 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') + + # Use only VRR in whitelisted outputs + 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') + + # Only update output if nesseccary to avoid flickering + [[ $output_vrr_status = "disabled" && $window_fullscreen_status = "1" ]] && swaymsg output "${output_name}" adaptive_sync 1 + [[ $output_vrr_status = "enabled" && $window_fullscreen_status = "0" ]] && swaymsg output "${output_name}" adaptive_sync 0 + fi + fi +done diff --git a/user/sway/default.nix b/user/sway/default.nix index c7b81f5..f2ab0bd 100644 --- a/user/sway/default.nix +++ b/user/sway/default.nix @@ -138,6 +138,21 @@ in services.gpg-agent.pinentry.package = pkgs.pinentry-all; + systemd.user.services.vrr-fullscreen = { + Unit = { + Description = "Enable VRR for fullscreen windows"; + PartOf = [ "graphical-session.target" ]; + After = [ "graphical-session.target" ]; + }; + Service = { + ExecStart = "${lib.getExe pkgs.vrr-fullscreen}"; + Restart = "on-failure"; + }; + Install = { + WantedBy = [ "sway-session.target" ]; + }; + }; + xdg.configFile."OpenTabletDriver/settings.json" = { force = true; source = ./open-tablet-driver.json;