Este programa irá sair após o xscreensaver ser desbloqueado (ou "não protegido" após uma ativação que não exija uma senha):
#!/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