32 lines
1.0 KiB
Bash
Executable File
32 lines
1.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Manual screen-lock for mango.
|
|
# - Locks via waylock (immediate lockscreen).
|
|
# - While locked, runs an aggressive 10 s idle blanker.
|
|
# - Pauses kanshi during blank to prevent profile flip-flop on the
|
|
# Lenovo USB-C dock (DP-MST drops link on DPMS off).
|
|
# - Cleans up on unlock.
|
|
|
|
set -e
|
|
|
|
# Don't stack lockers if one is already running (re-press, or
|
|
# before-sleep firing while already locked).
|
|
pgrep -x waylock >/dev/null && exit 0
|
|
|
|
# Short-timeout idle blanker, only alive while we're locked.
|
|
swayidle -w \
|
|
timeout 10 'pkill -STOP kanshi 2>/dev/null; wlopm --off "*"' \
|
|
resume 'wlopm --on "*"; sleep 0.5; pkill -CONT kanshi 2>/dev/null' \
|
|
>/dev/null 2>&1 &
|
|
LOCK_IDLE_PID=$!
|
|
|
|
# Cleanup on unlock: stop the idle watcher, ensure outputs are on,
|
|
# and resume kanshi in case the trap fires mid-blank.
|
|
trap '
|
|
kill "$LOCK_IDLE_PID" 2>/dev/null || true
|
|
wlopm --on "*" 2>/dev/null || true
|
|
pkill -CONT kanshi 2>/dev/null || true
|
|
' EXIT
|
|
|
|
# Block here until waylock exits on successful auth.
|
|
waylock
|