#!/bin/bash xscreensaver-command -watch | I=1 while read TEXT; [[ $TEXT != *UNBLANK* ]]; do [[ $TEXT == *RUN* ]] && ((I++)) if ((I>4)); then xfce4-session-logout break fi done