Swayscript : Fix multiple toggles.

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

View file

@ -20,11 +20,8 @@
# Toggle monitors. # Toggle monitors.
function montoggle() { function montoggle() {
if [[ "$(_monstate)" = "on" ]]; then local state=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .power')
monoff ''${state} && monoff || monon
else
monon
fi
} }
function monbar() { function monbar() {
@ -78,11 +75,8 @@
# Toggle gaming. # Toggle gaming.
function gamingtoggle() { function gamingtoggle() {
if [[ "$(_gamingstate)" = "on" ]]; then local state=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .adaptive_sync_status')
gamingoff [[ "''${state}" = "disabled" ]] && gamingon || gamingoff
else
gamingon
fi
} }
function _gamingstate() { function _gamingstate() {