2024-05-08 18:26:33 +03:00
|
|
|
{ ... }: {
|
|
|
|
text = ''
|
|
|
|
# Enable monitors.
|
|
|
|
function monon() {
|
|
|
|
on() {
|
2024-06-27 20:26:30 +03:00
|
|
|
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"
|
2024-05-08 18:26:33 +03:00
|
|
|
_monstate on
|
|
|
|
}
|
|
|
|
_sway_iterate_sockets on
|
|
|
|
}
|
|
|
|
|
|
|
|
# Disable monitors.
|
|
|
|
function monoff() {
|
|
|
|
off() {
|
2024-06-27 20:26:30 +03:00
|
|
|
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"
|
2024-05-08 18:26:33 +03:00
|
|
|
_monstate off
|
|
|
|
}
|
|
|
|
_sway_iterate_sockets off
|
|
|
|
}
|
|
|
|
|
|
|
|
# Toggle monitors.
|
|
|
|
function montoggle() {
|
2024-05-08 21:12:48 +03:00
|
|
|
if [[ "$(_monstate)" = "on" ]]; then
|
2024-05-08 18:26:33 +03:00
|
|
|
monoff
|
2024-05-08 21:12:48 +03:00
|
|
|
else
|
|
|
|
monon
|
2024-05-08 18:26:33 +03:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2024-05-08 18:26:33 +03:00
|
|
|
function _monstate() {
|
|
|
|
if [[ "''${1}" = "" ]]; then
|
2024-05-08 19:50:09 +03:00
|
|
|
cat /tmp/.monstate 2> /dev/null || echo on
|
2024-05-08 18:26:33 +03:00
|
|
|
else
|
|
|
|
echo "''${*}" > /tmp/.monstate
|
|
|
|
fi
|
|
|
|
}
|
2024-08-22 19:13:40 +03:00
|
|
|
|
|
|
|
function _recording() {
|
|
|
|
[[ "$(ps cax | rg wf-recorder)" = "" ]] && echo off || echo on
|
|
|
|
}
|
2024-05-08 18:26:33 +03:00
|
|
|
'';
|
|
|
|
}
|