check-idle() {
export DISPLAY=:0
- idle_time=$(xprintidle 2>/dev/null) ||:
# 3 hours, assume a movie might run that long.
- if [[ $idle_time ]] && (( idle_time < 1000 * 60 * 60 * 3 )); then
+ idle_limit=$((1000 * 60 * 60 * 3))
+ idle_time=$idle_limit
+ id=999
+ while id $((++id)) &>/dev/null; do
+ new_idle_time=$(sudo -u \#$id xprintidle 2>/dev/null) ||:
+ if [[ $new_idle_time && $new_idle_time -lt $idle_time ]]; then
+ idle_time=$new_idle_time
+ fi
+ done
+ if (( idle_time < idle_limit )); then
idle=false
else
idle=true
# the wiki recommends 30 days or so, but
# it makes the comp lag like shit for a day,
# so I'm going with 90 days.
- if (( $date > `date +%s` - 60*60*24*30 )); then
+ if (( date > $(date +%s) - 60*60*24*30 )); then
echo "cron: skiping scrub of $mnt"
continue
fi