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

50 lines
973 B
Nix
Raw Normal View History

# TODO: Add different modes for different screens.
{ ... }: {
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"
swaymsg "output \"''${vrr}\" mode 3440x1440@164.999Hz"
done
_vrrstate on
}
_sway_iterate_sockets on
}
# Disable VRR.
function vrroff() {
off() {
for vrr in ''${_swayvrrlist[@]}; do
swaymsg "output \"''${vrr}\" adaptive_sync off"
swaymsg "output \"''${vrr}\" mode 3440x1440@59.973Hz"
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
}
'';
}