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

17 Comments

  1. Nice work =)

    Comment by Michael — June 29, 2009 @ 12:30 am

  2. Also I suggest changing the installation instructions as to such to make it easier to follow and for a cleaner install:

    wget http://drive.heartinternet.co.uk/F/685729-744778967/MTA0YjZmOTJjNTdkOGU5YWY5NTVlMDZiZDE2ZmVlZGY=
    mkdir -p .opt/caffeine
    tar -xvf caffeine-0.1.tar.gz -C .opt/caffeine
    rm caffeine-0.1.tar.gz

    Comment by Michael — June 29, 2009 @ 12:36 am

    • Unfortunately, I think that the Heart Drive people actually change the long string at the end of the download link every so often, or perhaps based on a person’s IP. I tried that wget command, and it seems to have stopped working. I guess they want everyone to go and see their ads in order to download a file. I imagine that this problem will go away when the project moves to an open-source project hosting web site.

      Comment by bnsmith — June 29, 2009 @ 8:25 am

  3. 1 a DEB package for easier installation
    3 uploading the source-code to a proper project-hosting web-site, like Launchpad, Sourceforge or Google Code (which would you prefer?)
    4 keyboard shortcuts to control the program without using the mouse
    2 ability to activate for a fixed amount of time before allowing regular powersaving to resume (a useful feature of the Mac OS version)
    5 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)
    6 proper KDE support (I don’t really care, but sure, why not)

    Comment by starcannon — June 29, 2009 @ 1:23 am

  4. Getting an error saying:
    “Error: couldn’t find bus to allow inhibiting of the screen saver.
    Please visit the web-site listed in the ‘About’ dialog of this application and check for a newer version of the software.”
    I’m running pretty much vanilla Ubuntu 9.04.

    Also, how would you like some nicer icons? The ones you have now are quite pixelated and don’t look all that great. A proper .svg would probably look better. If you’d like, I can whip something up for you.

    Comment by tommybrunn — June 29, 2009 @ 3:54 am

    • There! I’ve got two spanking new icons for you to use, if you’d like. They are both .SVGs, so they’ll scale nicely, unlike the current .PNG icons.

      Hope you like them! I’ve tried them out, and I think they look pretty darn good, if I may say so myself.

      http://www.petaimg.com/u388/988fullcup.svg
      http://www.petaimg.com/u220/72emptycup.svg

      Comment by tommybrunn — June 29, 2009 @ 6:48 am

      • Wow! Thanks for the icons! I made the original ones myself, and I’m definitely not much of a graphic artist ๐Ÿ™‚

        I was expecting that I would have to build up this open-source project over a period of years before a real artist would volunteer to improve the icons… and now here you are. It’s only been a couple of days!

        Comment by bnsmith — June 29, 2009 @ 8:11 am

  5. Well, I’ve used another application for that. I often use my MBP as a music station. when I do I put iTunes on shuffle and let the music blast away.

    But I wanted to do this whilst having the lid closed : solution : http://www.versiontracker.com/dyn/moreinfo/macosx/30315 something alike to caffein. No more sleepy laptop.

    Comment by microwaver — June 29, 2009 @ 8:06 am

  6. Nifty app. ๐Ÿ™‚

    As far as a public source repository, may I recommend Gitorious?

    Comment by Chris Howie — June 29, 2009 @ 9:42 am

  7. So this is gnome-screensaver only just now?

    Might I suggest also supporting xscreensaver?

    Comment by Stephen Paul Weber — June 29, 2009 @ 6:45 pm

    • It’s only fully functional for Gnome at the moment, but support for other Window managers and things is the #1 most requested new feature. So far people have requested FluxBox, OpenBox, Xfce and dpms. So I’ll definitely add xscreensaver to the list.

      Comment by bnsmith — June 30, 2009 @ 8:06 am

  8. Also, you probably shouldn’t say “for Linux” but rather “for GNOME-screensaver” and later “and X and Y” if you add other screensaver daemons

    Comment by Stephen Paul Weber — June 29, 2009 @ 6:46 pm

    • I hadn’t really thought about that. I guess I’m hoping to ramp up to supporting multiple Window Managers very soon, and once I support KDE, FluxBox, Xfce, OpenBox, dpms and xscreensaver, I won’t feel bad about calling it “Caffeine for Linux”.

      Comment by bnsmith — June 30, 2009 @ 8:10 am

  9. Just to give everyone a bit of an update, I have done some more testing of the Gnome “Inhibit” applet. It does seem to properly prevent my laptop from going to sleep. However, it doesn’t prevent the screensaver from activating. I’m not sure if this is a bug that was introduced with Ubuntu 9.04, or if this is the way that it is intended to behave…

    I’ve also discovered a bug that you may have encountered. If you log-in to your desktop, and then immediately click on the coffee-cup as soon as you see it, you may get an error dialog box popping up, saying that it can’t connect to the bus. This is because the screensaver bus apparently takes an extra few seconds to start after Caffeine is up and running. I should probably insert a 30 second delay or something if the bus isn’t found. Anyway, if you see that, it’s a known bug.

    Comment by bnsmith — June 30, 2009 @ 9:44 am

  10. Yes a deb package would be much appreciated.

    Thanks.

    Comment by Adam York — July 23, 2009 @ 8:26 pm

    • Caffeine is now available through a Launchpad PPA. Will that work for you? See the update at the top of the post.

      Comment by bnsmith — July 23, 2009 @ 9:07 pm


RSS feed for comments on this post.

Create a free website or blog at WordPress.com.

%d bloggers like this: