A kind of an alarm clock


One thing I’ve writ­ten about before is the prob­lem of Compulsive Inter­net Use before. One thing I’ve tried in the past to deal with is was my Shutdown Nag. This, at the time, was a quick exten­sion to my Window Manager which would lock the com­puter at a pre­set time and then give me the oppor­tu­nity to save my work before shut­ting the com­puter down for the night. It worked rea­son­ably well, but I’ve since changed the win­dow man­ager I use from Stumpwm to Xmonad and the old tool no longer works. I’ve since intended to replace it with a sim­i­lar win­dow man­ager agnos­tic tool, but had­n’t the will to actu­ally go through the effort to write it, until now.

My new pro­gram, Nighttime-Alert is a quick C pro­gram, which I hacked together ini­tially by retool­ing code from dmenu. Then I skimmed some actu­ally docs on how to use XLib and made it work in the way that I want­ed. That way is this:

  1. The program is triggered by cron to start to start at 10:00 PM. (It can be made to start at anytime, but I chose 10:00 PM)
  2. The program locks the keyboard and mouse and flashes a message announcing that the computer will shutdown soon.
  3. I can then press escape to make the message go away and save my work.
  4. The message returns every 3 minutes.
  5. At 10:30 PM, the program locks the keyboard and mouse again and shuts down the computer. (The shutdown time is set with a CLI option in the cron job)

Sim­ple and it keeps me from acci­den­tally brows­ing the Inter­net past my (self-im­posed) bed­time. Also, it looks kinda cool:

ScreenShot

For those who want to try it them­selves, it’s on Github and it should be a breeze to com­pile and run. The only require­ments are that it run on a Linux com­puter run­ning X Win­dows and sys­temd, so most of them. 1

  1. It can be made to work without systemd trivially, but I haven’t done so. Patches are welcome. 

Last update: 08/03/2013

blog comments powered by Disqus