fix lock on lid closed

This commit is contained in:
Dmitri 2026-04-15 19:23:15 +02:00
parent 55ac166402
commit 7d0c2d7937
Signed by: kanopo
GPG Key ID: 759ADD40E3132AC7
2 changed files with 9 additions and 9 deletions

View File

@ -173,6 +173,7 @@
{ {
"colorizeDistroLogo": false, "colorizeDistroLogo": false,
"colorizeSystemIcon": "secondary", "colorizeSystemIcon": "secondary",
"colorizeSystemText": "none",
"customIconPath": "", "customIconPath": "",
"enableColorization": true, "enableColorization": true,
"icon": "noctalia", "icon": "noctalia",
@ -398,7 +399,7 @@
"customCommands": "[]", "customCommands": "[]",
"enabled": true, "enabled": true,
"fadeDuration": 5, "fadeDuration": 5,
"lockCommand": "qs -c noctalia-shell ipc call session lock", "lockCommand": "sh -c '/usr/sbin/playerctl -a pause >/dev/null 2>&1 || true; /usr/sbin/qs -c noctalia-shell ipc call lockScreen lock'",
"lockTimeout": 300, "lockTimeout": 300,
"resumeLockCommand": "", "resumeLockCommand": "",
"resumeScreenOffCommand": "swaymsg \"output * dpms on\"", "resumeScreenOffCommand": "swaymsg \"output * dpms on\"",

View File

@ -3,20 +3,19 @@
action="$1" action="$1"
internal="${2:-eDP-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)" external_active_count="$(swaymsg -t get_outputs | python3 -c 'import json,sys; internal=sys.argv[1]; outputs=json.load(sys.stdin); print(sum(1 for o in outputs if o.get("active") and o.get("name") != internal and not o.get("non_desktop", False)))' "$internal" 2>/dev/null)"
if [ -z "$active_count" ]; then if [ -z "$external_active_count" ]; then
active_count=1 external_active_count=0
fi fi
case "$action" in case "$action" in
on) on)
if [ "$active_count" -le 1 ]; then if [ "$external_active_count" -gt 0 ]; then
qs -c noctalia-shell ipc call session lock
sleep 1
systemctl suspend
else
swaymsg "output $internal disable" swaymsg "output $internal disable"
else
/usr/sbin/playerctl -a pause >/dev/null 2>&1 || true
/usr/sbin/qs -c noctalia-shell ipc call lockScreen lock
fi fi
;; ;;
off) off)