![xscreensaver가 잠금 해제될 때까지 어떻게 기다릴 수 있나요?](https://linux55.com/image/122816/xscreensaver%EA%B0%80%20%EC%9E%A0%EA%B8%88%20%ED%95%B4%EC%A0%9C%EB%90%A0%20%EB%95%8C%EA%B9%8C%EC%A7%80%20%EC%96%B4%EB%96%BB%EA%B2%8C%20%EA%B8%B0%EB%8B%A4%EB%A6%B4%20%EC%88%98%20%EC%9E%88%EB%82%98%EC%9A%94%3F.png)
xscreensaver가 잠금 해제될 때까지 어떻게 기다릴 수 있나요? xscreensaver-command -lock
화면을 잠그고 화면이 다시 잠금 해제되기 전에 돌아가세요. xscreensaver는 이벤트를 xscreensaver-command -watch
인쇄 하는 방법을 제공 하지만 이벤트를 구문 분석하고 나중에 종료되는지 UNBLANK
어떻게 확인합니까 ?xscreensaver-command -watch
답변1
xscreensaver가 잠금 해제된 후(또는 비밀번호가 필요하지 않은 활성화 후 "잠금 해제"된 후) 프로그램이 종료됩니다.
#!/bin/bash
set -eu
FIFO=/tmp/xscreensaver-wait-for-unlock-$$.fifo
rm -f "$FIFO"
mkfifo "$FIFO"
# Kill `xscreensaver-command -watch` when we exit
trap "exit" INT TERM
trap "kill %1; rm -f $FIFO" EXIT
xscreensaver-command -watch > $FIFO &
while read line; do
if echo -E "$line" | grep -q "^UNBLANK "; then
# Make sure the screen is actually unlocked
xscreensaver-command -time | grep -q " screen non-blanked since " && exit 0 || echo "saw UNBLANK but screen was not unlocked"
fi
done < $FIFO