nix/package/swayscript/script/Monitor.nix

55 lines
1.3 KiB
Nix
Raw Normal View History

{ ... }: {
text = ''
# Enable monitors.
function monon() {
on() {
swaymsg "output \"ASUSTek COMPUTER INC ASUS VA24E R2LMTF127165\" power on"
swaymsg "output \"AU Optronics 0x418D Unknown\" power on"
swaymsg "output \"AOC 24G2W1G4 ATNL61A129625\" power on"
_monstate on
}
_sway_iterate_sockets on
}
# Disable monitors.
function monoff() {
off() {
swaymsg "output \"ASUSTek COMPUTER INC ASUS VA24E R2LMTF127165\" power off"
swaymsg "output \"AU Optronics 0x418D Unknown\" power off"
swaymsg "output \"AOC 24G2W1G4 ATNL61A129625\" power off"
_monstate off
}
_sway_iterate_sockets off
}
# Toggle monitors.
function montoggle() {
2024-05-08 21:12:48 +03:00
if [[ "$(_monstate)" = "on" ]]; then
monoff
2024-05-08 21:12:48 +03:00
else
monon
fi
}
2024-05-08 21:12:48 +03:00
function monbar() {
2024-05-24 03:43:20 +03:00
local __monstate=$(_monstate)
2024-07-27 03:35:59 +03:00
local __gamingstate=$(_gamingstate)
2024-05-24 03:43:20 +03:00
local class=""
2024-07-27 03:35:59 +03:00
if [[ "''${__monstate}" = "off" ]] || [[ "''${__gamingstate}" = "on" ]]; then
2024-05-24 03:43:20 +03:00
class="modified"
fi
2024-07-27 03:35:59 +03:00
printf "{\"text\": \"󰍹\", \"tooltip\": \"Monitor: ''${__monstate^} / Gaming: ''${__gamingstate^}\", \"class\": \"''${class}\"}\n"
2024-05-08 21:12:48 +03:00
}
function _monstate() {
if [[ "''${1}" = "" ]]; then
cat /tmp/.monstate 2> /dev/null || echo on
else
echo "''${*}" > /tmp/.monstate
fi
}
'';
}