Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 47 lines (39 sloc) 900 Bytes
#!/bin/bash
me=`basename $0`
usage () {
if [ -n "$1" ]; then
echo "$*" >&2
echo
fi
cat <<EOF >&2
Usage: $me THRESHOLD
EOF
exit 1
}
if [ "$1" == '-h' ] || [ "$1" == '--help' ]; then
usage
fi
if [ -z "$1" ]; then
usage
fi
threshold_epoch=`date +%s -d "$*"`
threshold_human=`date -d "$*"`
# don't use uidle -x since we don't want mouse movement
# to trigger a reboot!
if ! last_active_epoch=`uidle -lx`; then
uidle -lx -v5 > ~/.log/uidle-lx.broke 2>&1
echo "uidle -l failed; aborting." >&2
exit 1
fi
if ! last_active_human=`uidle -lhx`; then
uidle -lhx -v5 > ~/.log/uidle-lhx.broke 2>&1
echo "uidle -lh failed; aborting." >&2
exit 1
fi
if [ "$last_active_epoch" -gt "$threshold_epoch" ]; then
echo "$last_active_human; after $threshold_human"
exit 0
else
echo "$last_active_human; before $threshold_human"
exit 1
fi