Automatic alerts of time spent on computer
June 1, 2009 8:57 AM Subscribe
Does anyone know a way to create alerts in Ubuntu every x number of minutes of how long spent on the computer that day?
I think an alert system of how long spent on the computer that day would really help with my time management. I don't know if an application or script would be what I am looking for. I tried the hamster time tracking panel app, but that is less ideal, because I can forget to get it to start tracking.
I think an alert system of how long spent on the computer that day would really help with my time management. I don't know if an application or script would be what I am looking for. I tried the hamster time tracking panel app, but that is less ideal, because I can forget to get it to start tracking.
Also the command "w" in a terminal will show you what time you logged in.
posted by Luddite at 9:03 AM on June 1, 2009
posted by Luddite at 9:03 AM on June 1, 2009
As a DIY coding project, it's not too hard...
It's easy enough to write a program that runs in the background and pops up an alert periodically. The harder question is how to determine "how long spent on the computer" --- uptime just tells you how long the computer has been on.
xscreensaver has idle information, available to through the libxss API. More convenient would be something like this Python xss module, which you could use to poll the screensaver and record idle status. From that you could put together a pretty good estimate.
posted by qxntpqbbbqxl at 9:24 AM on June 1, 2009
It's easy enough to write a program that runs in the background and pops up an alert periodically. The harder question is how to determine "how long spent on the computer" --- uptime just tells you how long the computer has been on.
xscreensaver has idle information, available to through the libxss API. More convenient would be something like this Python xss module, which you could use to poll the screensaver and record idle status. From that you could put together a pretty good estimate.
posted by qxntpqbbbqxl at 9:24 AM on June 1, 2009
Try zenity for the popup. Something like "zenity --info --text='You have been on the computer for n minutes today.'"
I like the idea of using who/w for time tracking. How about "w | awk '{print $6}'" to get your recent usage? If there are multiple users you might have to grep them out. Call this once a minute and grep for two digits followed by an s (indicating that you've used the machine that many seconds ago). If you do have results in that many seconds, add one to your minute counter. If not, assume you're idle and do nothing. Then open zenity reading your minute counter as often as needed.
Note that this is the quick and dirty method, and libxss would be better.
posted by valadil at 10:28 AM on June 1, 2009
I like the idea of using who/w for time tracking. How about "w | awk '{print $6}'" to get your recent usage? If there are multiple users you might have to grep them out. Call this once a minute and grep for two digits followed by an s (indicating that you've used the machine that many seconds ago). If you do have results in that many seconds, add one to your minute counter. If not, assume you're idle and do nothing. Then open zenity reading your minute counter as often as needed.
Note that this is the quick and dirty method, and libxss would be better.
posted by valadil at 10:28 AM on June 1, 2009
You could also grep the process list (ps) for programs that you use while working, have that cron'd every 15 minutes or so, and update a tally of 15-min blocks and the equivalent hours (n/4) to a date-based filename.
posted by cowbellemoo at 11:36 AM on June 1, 2009
posted by cowbellemoo at 11:36 AM on June 1, 2009
quick 'n' dirty (slight) expansions on valadil's idea:
to pop up once every 15 minutes, maybe this?
posted by namewithoutwords at 11:42 AM on June 1, 2009
zenity --info --text="$(w -h)"
would pop up the relevant w outputto pop up once every 15 minutes, maybe this?
while true; do zenity --info --text="$(w -h)"; sleep 15m; done
posted by namewithoutwords at 11:42 AM on June 1, 2009
I use this script to pop up a reminder every 15 minutes on my computer:
It wouldn't be too hard to modify this script so that you write out the time to a file, then every 15 minutes, read that time, increment it, display the result, and write it back to the file.
posted by chrisamiller at 1:33 PM on June 1, 2009
#!/bin/bash
#kill any previous boxes
kill $(ps aux | grep "Right now:" | grep -v "grep" | awk '{print $2}')
#now start a new one
zenity --question --title "Alert" --text "Right now: Is this really what you want to be doing?"
save it somewhere, then edit your crontab (using 'crontab -e') to add the script:
0,15,30,45 * * * * export DISPLAY=:0 && bash /path/to/yourscript.sh 2> /dev/null
It wouldn't be too hard to modify this script so that you write out the time to a file, then every 15 minutes, read that time, increment it, display the result, and write it back to the file.
posted by chrisamiller at 1:33 PM on June 1, 2009
You also might try the excellent time-tracker applet, which can add to your panel by right-clicking. (aka project hamster)
posted by chrisamiller at 1:34 PM on June 1, 2009
posted by chrisamiller at 1:34 PM on June 1, 2009
This thread is closed to new comments.
posted by aheckler at 9:00 AM on June 1, 2009