Pragmattica

June 27, 2009

Caffeine: Not Just for Beverages Anymore

Filed under: Linux — bnsmith @ 10:27 pm

Update: The new 1.0 version of Caffeine has been released.

The information in this post is now obsolete.

Please see this post for more information.

A few months ago, I attended a little get-together for software developers to share their projects and passions. One of the presenters that night faced the unfortunate situation of having his laptop repeatedly enter sleep mode as he discussed one of his slides. This caused the projector to blank out, interrupting his flow and forcing him to run over to his laptop to press a key.

After the presentation was over, one of the attendees demonstrated a handy utility that could have saved the presenter some embarrassment: Caffeine.

Another Example of Superbly-Designed Software for Mac OS

The idea is simple enough. The program consists of a little coffee-cup applet that sits on the right-hand side of the menu bar. The coffee-cup starts out empty, meaning that the applet is inactive.

01_mac_empty

When you click the empty cup, it fills up with coffee and begins preventing your computer from either activating the screensaver or entering sleep mode. Caffeine keeps your computer awake!

02_mac_full

And slideshow presentations is just the beginning. With Caffeine, you can watch long YouTube or Hulu videos without having to remember to lick the Cheeto-dust off your fingers and then hit a key every few minutes.

If you use a Mac, I suggest that you head over to Lighthead Software and download Caffeine right now. As soon as I saw it, I knew that I would have to track down whatever the Linux equivalent was and install it on my machine.

A Surprising Discovery

It took several hours of careful searching before I was finally forced to accept the shocking truth: there was no Linux equivalent. This is a highly unusual circumstance these days. There are some cases where the Linux equivalent of some piece of software is not as good as what’s available on the other platform, but there’s almost always… something.

My annoyance at the lack of an equivalent for this handy utility was quickly replaced by excitement, because I realized that this was an opportunity for me to make an important contribution. Which brings me to my next point. I am pleased to announce the immediate availability of the first public release of…

Caffeine for Linux

Following the philosophy of “Release Early, Release Often”, the 0.1 release of Caffeine for Linux is very rudimentary and could well contain major bugs. The largest problem that I know of is its incomplete support for KDE. The applet will run under KDE, but activating it will only prevent the screensaver from starting; the activation of sleep mode is not prevented.

Instead of spending all sorts of time thinking about which new features I should implement, I’d like to put you in charge of determining the priorities for future development. If there are any features that you would like to see implemented, just leave a comment and I’ll get to work. Just to get things started, here are a couple of ideas that popped into my head:

  • proper KDE support
  • a DEB package for easier installation
  • uploading the source-code to a proper project-hosting web-site, like Launchpad, Sourceforge or Google Code (which would you prefer?)
  • keyboard shortcuts to control the program without using the mouse
  • ability to activate for a fixed amount of time before allowing regular powersaving to resume (a useful feature of the Mac OS version)
  • ability to activate automatically when a certain program runs (there are some full-screen games for Linux that unfortunately allow the screen-saver to activate while you play)

Of course, these are just ideas that sound good to me. You’re the ones that are running this operation.

Installation Instructions

The following step-by-step instructions are meant for Ubuntu 9.04; users of other distributions will likely need to adjust for small differences. Also, be sure to substitute your username whenever you see <<yourusername>>.

  • Download this file to your home directory
  • Open a Terminal by clicking Applications -> Accessories -> Terminal
  • In the Terminal, execute the following commands, one at a time:
mkdir -p opt/caffeine
tar -xvf caffeine-0.1.tar.gz -C opt/caffeine
rm caffeine-0.1.tar.gz
  • Go to System -> Preferences -> Startup Applications
  • Click Add
  • Set the “Name” field to Caffeine and the “Command” field to /home/<<yourusername>>/opt/caffeine/caffeine.py
  • Click Add and then Close
  • Log out and log back in; the Caffeine applet should appear in the top-right

03_linux_empty

  • Click the icon to activate it

04_linux_full

That’s it. You should now be able to sit back and take in a mind-blowing video like this one without power-saving getting in the way. As always, leave a comment if you have any problems.

Advertisements

Blog at WordPress.com.