nix/module/desktop/sway/script/Vrr.nix

47 lines
803 B
Nix
Raw Normal View History

{ ... }: {
text = ''
export _swayvrrlist=(
"Huawei Technologies Co., Inc. ZQE-CBA 0xC080F622"
)
# Enable VRR.
function vrron() {
on() {
for vrr in ''${_swayvrrlist[@]}; do
swaymsg "output \"''${vrr}\" adaptive_sync on"
done
_vrrstate on
}
_sway_iterate_sockets on
}
# Disable VRR.
function vrroff() {
off() {
for vrr in ''${_swayvrrlist[@]}; do
swaymsg "output \"''${vrr}\" adaptive_sync off"
done
_vrrstate off
}
_sway_iterate_sockets off
}
# Toggle VRR.
function vrrtoggle() {
2024-05-08 19:22:04 +03:00
if [[ "$(_vrrstate)" = "on" ]]; then
vrroff
2024-05-08 19:22:04 +03:00
else
vrron
fi
}
function _vrrstate() {
if [[ "''${1}" = "" ]]; then
2024-05-08 21:12:48 +03:00
cat /tmp/.vrrstate 2> /dev/null || echo off
else
echo "''${*}" > /tmp/.vrrstate
fi
}
'';
}