I’ve read a very interesting article about “Why programmers work at night”. One of the points the author talks about is “how we get engrossed in twitter/hacker news/reddit”. I’ve felt the same. I think one of the reasons why we(programmers/developers) spend a lot of our time on twitter/hacker news/reddit is, because, we don’t have any idea of the time. Time just flies by. So, I created a small ruby script which nags you to get back to work :)
1 #!/usr/bin/env ruby
2 require 'time'
3
4 exit if File.exists?("/tmp/stop-nagging")
5 #see what I did here ;)
6
7 #run the below command to find your display
8 #env | grep DISPLAY
9 ENV['DISPLAY'] = ':0.0'
10
11 last_line = `tail -2 ~/.gtimelog/timelog.txt`.lines.map{|x| x.chomp}.reject{|x| x.empty?}.reverse.first
12 minutes = ((Time.now - Time.parse(last_line[11, 5])) / 60).round
13 evil_monkey = File.expand_path File.join(File.dirname(__FILE__), 'evil-monkey.gif')
14
15 if minutes > 30
16 `notify-send -i '#{evil_monkey}' "It's been #{minutes} minutes since your last log"`
17 end
1 0,5,10,15,20,25,30,35,40,45,50,55 * * * * /bin/bash -l -c '/home/minhajuddin/.scripts/nagger'

Hope it helps you get back to work too :). By the way, I use the awesome gtimelog app to log my time.