Tuesday, March 19, 2013

Code To Make You Walk

A little while ago I hacked my crontab to remind me to walk every 25 minutes:

However, this was flawed. Because it runs all day long, it can tell you to walk for five minutes the minute you first turn on your computer. It started doing this with me, so I started ignoring it. But an organizational system you ignore is worse than none at all, so I'm trying a different tactic. This is a bash function from my ~/.profile:

The $() syntax executes the rest of it in a subshell, and the & at the end backgrounds the process. So every time you sit down at the computer, you tell the computer to remind you to walk if you're still sitting down at the computer once 25 minutes have elapsed. If you decide to get up and go somewhere before the 25 minutes have elapsed, you just exit the shell; it'll remind you that you have background jobs, and you can kill the job, so you don't get this backlog of irrelevant reminders.

Otherwise, of course, it'll tell you to stop walking after another 5 minutes have passed. sleep takes a number of seconds, and 1500 seconds is 25 minutes, while 1800 seconds is 30 minutes. I learned how to build this function by writing my illustrated ebook Legend Of The Burned Hart Style, and I got the idea of using shell scripting this way from the book Time Management For System Administrators.