Swayscript : Toggle gaming for monitors under cursor.

This commit is contained in:
Dmitry Voronin 2024-09-08 03:18:25 +03:00
parent edca25ead8
commit 1c7afa8072
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k

View file

@ -61,11 +61,8 @@
# Enable Gaming. # Enable Gaming.
function gamingon() { function gamingon() {
on() { on() {
swaymsg "output \"Huawei Technologies Co., Inc. ZQE-CBA 0xC080F622\" adaptive_sync on" local output=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name')
# swaymsg "output \"Huawei Technologies Co., Inc. ZQE-CBA 0xC080F622\" mode 3440x1440@164.999Hz" swaymsg "output \"''${output}\" adaptive_sync on"
swaymsg "output \"AOC 24G2W1G4 ATNL61A129625\" adaptive_sync on"
# swaymsg "output \"AOC 24G2W1G4 ATNL61A129625\" mode 1920x1080@144.000Hz"
_gamingstate on
} }
_sway_iterate_sockets on _sway_iterate_sockets on
} }
@ -73,11 +70,8 @@
# Disable Gaming. # Disable Gaming.
function gamingoff() { function gamingoff() {
off() { off() {
swaymsg "output \"Huawei Technologies Co., Inc. ZQE-CBA 0xC080F622\" adaptive_sync off" local output=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name')
# swaymsg "output \"Huawei Technologies Co., Inc. ZQE-CBA 0xC080F622\" mode 3440x1440@59.973Hz" swaymsg "output \"''${output}\" adaptive_sync off"
swaymsg "output \"AOC 24G2W1G4 ATNL61A129625\" adaptive_sync off"
# swaymsg "output \"AOC 24G2W1G4 ATNL61A129625\" mode 1920x1080@60.000Hz"
_gamingstate off
} }
_sway_iterate_sockets off _sway_iterate_sockets off
} }
@ -92,11 +86,17 @@
} }
function _gamingstate() { function _gamingstate() {
if [[ "''${1}" = "" ]]; then local outputs=($(swaymsg -t get_outputs | jq -r '.[] | .adaptive_sync_status'))
cat /tmp/.gamingstate 2> /dev/null || echo off
else for state in "''${outputs[@]}"; do
echo "''${*}" > /tmp/.gamingstate [[ "''${state}" = "disabled" ]] || {
fi echo on
return 1
}
done
echo off
return 0
} }
''; '';
} }