To clean the mess you left on computer, run screensaver or shut down unoccupied computer get idle time and run script that do things when computer become idle.
Time when no movement of mouse/other input occured) can be obtained with looping script that check on mouse movements nad run command when there was no movement in some period of time:
#!/bin/bash
sleep 60
sleep 60
rm mousemovementsfile
#erase file from previous session
#erase file from previous session
sleep 1
#thread writing mousemovements to file -check your inputs
cat -n /dev/input/by-path/pci-0000:00:1d.7-usb-0:2.1:1.0-event-mouse > mousemovementsfile&
while (true)
do
#check size
filesize1=$(stat -c%s "mousemovementsfile")
#wait 70 second or something
sleep 600
#check second size,compare, execute idle scritp if same size
filesize2=$(stat -c%s "mousemovementsfile")
#compare
if [ "$filesize1" -eq "$filesize2" ]
then
#execute idle script
/usr/bin/notify-send -u normal -t 7000 \
'this is only running when user is not present at computer' 'this is only running when user is not present at computer'
fi
echo notidle
done
alternative solution in c language:
via http://coderrr.wordpress.com/2008/04/20/getting-idle-time-in-unix/#comments
0 comments:
Post a Comment