26 lines
574 B
Bash
Executable File
26 lines
574 B
Bash
Executable File
#!/bin/sh
|
|
|
|
action="$1"
|
|
internal="${2:-eDP-1}"
|
|
|
|
active_count="$(swaymsg -t get_outputs | python3 -c 'import json,sys; print(sum(1 for o in json.load(sys.stdin) if o.get("active")))' 2>/dev/null)"
|
|
|
|
if [ -z "$active_count" ]; then
|
|
active_count=1
|
|
fi
|
|
|
|
case "$action" in
|
|
on)
|
|
if [ "$active_count" -le 1 ]; then
|
|
qs -c noctalia-shell ipc call session lock
|
|
sleep 1
|
|
systemctl suspend
|
|
else
|
|
swaymsg "output $internal disable"
|
|
fi
|
|
;;
|
|
off)
|
|
swaymsg "output $internal enable"
|
|
;;
|
|
esac
|