nix/package/swayscript/script/Monitor.nix

62 lines
1.6 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"
swaymsg "output \"Chimei Innolux Corporation 0x1521 Unknown\" 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"
swaymsg "output \"Chimei Innolux Corporation 0x1521 Unknown\" 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-08-22 19:13:40 +03:00
local __recording=$(_recording)
2024-05-24 03:43:20 +03:00
local class=""
2024-08-22 19:13:40 +03:00
if [[ "''${__monstate}" = "off" ]] || [[ "''${__gamingstate}" = "on" ]] || [[ "''${__recording}" = "on" ]]; then
2024-05-24 03:43:20 +03:00
class="modified"
fi
2024-08-22 19:13:40 +03:00
printf "{\"text\": \"󰍹\", \"tooltip\": \"Monitor: ''${__monstate^} / Gaming: ''${__gamingstate^} / Recording: ''${__recording^}\", \"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
}
2024-08-22 19:13:40 +03:00
function _recording() {
[[ "$(ps cax | rg wf-recorder)" = "" ]] && echo off || echo on
}
'';
}