Categories
Code

Undistract: An Attention Watchdog

I’m posting my distraction defeating program undistract today and wanted to explain how it came about and why I find it useful.

I have problems with attention. I’ve not been diagnosed with A.D.D. or anything but anyone who spent fifteen minutes in my office would realize that I am either utterly distracted or hyper-focused. These are pretty common traits amongst scientists and programmers – indeed, the tendency to hyper-focus is probably the same thing that programmers call “being in the zone”.

I have designed it to solve a particular problem – I tend to focus on my work once I get started, but I also focus equally well on non-work activities, in particular web browsing. It’s easy for me to let an hour (or eight!!) pass whilst, say, checking Slashdot repeatedly, without realizing that so much time has gone by. I designed undistract to gently pull me out of this focus-on-distraction to give me a chance to focus on my work.

The program works by monitoring what windows are open on my desktop. I use GNOME on Ubuntu Linux (I also test the program in KDE and XFCE) with multiple workspaces (also called virtual desktops). I tend to have them arranged like

  • Workspace 1: Browser, Email, IM windows, music player
  • Workspace 2: Couple of xterms on local machine
  • Workspace 3: SSH & VNC sessions to machines on the cluster at work
  • Workspace 4: gvim editing analysis code or LaTeX files.

Clearly, if I am doing useful work, I ought to be spending most (but not all) of my time on Workspaces 3 & 4. Workspace 2 tends to involve distractions but not entirely useless ones, as I do things like update the operating system, tweak configuration, backup my data etc. If, however, I am spending a lot of time on Workspace 1, it is safe to assume that I have become absorbed in some distraction, whether it be Slashdot, MySpace, eBay… whatever it is, I have a thesis to write so it’s probably not helpful.

I do want to allow for those times when I’m in the flow, working on something, and I have to look up some documentation online. What I’m really trying to catch with Undistract are those times when you sit down to work, but just want to check your email, only to find someone emailed you a funny link, which led you to your browser, which led you to hover next to that open tab to Google News… if you have found this page, you know the story!

Undistract maintains a ‘nag level’ which is raised or lowered at intervals depending on whether the user has a browser open on the current workspace or not. The intervals for checking are not uniform, and when the nag level is low the checking occurs slowly, like every 10 minutes. If the user is still using a browser after that interval, then a message appears in front of all the open windows (using xosd) telling them to get to work, and the nag level is raised.

As the nag level increases, the interval between nags becomes shorter, up to a limit, by default 60 seconds. After the nag level passes a certain value, 6 by default, then the user is reminded to work by the xosd message but current workspace is changed. The user is free to change back to the browser and finish what they are doing, but after 60 seconds they will be bounced to a different desktop again.

If you think this could be helpful in helping with your own distractions, try undistract for a bit.