xscreensaver가 잠금 해제될 때까지 어떻게 기다릴 수 있나요?

xscreensaver가 잠금 해제될 때까지 어떻게 기다릴 수 있나요?

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

관련 정보