request: get caffeine indicator to show active when caffeinate is running

Bug #1639482 reported by Aaron Wolf on 2016-11-05
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

Not certain this makes sense, but it would seem ideal if running caffeinate could somehow have a visual indication of its running via the caffeine-indicator (and then potentially even cancel caffeinate via the indicator without stopping the command caffeinate is running with? Not sure there). Mostly, it would be nice to see a visual indication that caffeinate is running.

Reuben Thomas (rrt) wrote :

That's an interesting idea, but the way things work are messy.

First, caffeinate does currently require an X server to be running on which it can create a window, but that's a limitation of xdg-screensaver.

Secondly, the point of caffeine-indicator's indicator is to show whether the screensaver is currently inhibited _by caffeine-indicator_, not whether the screensaver is currently inhibited.

One thing that could be done is for caffeine-indicator to show both whether the screensaver is currently inhibited, and to have an extra way to show that it's currently doing the inhibiting. The first way would most logically be the same as at present (the status icon); the second way could be some sort of accent on the icon, or it could be in the menu (as currently you can see from the menu item saying "Deactivate", but perhaps by using a tick instead).

To work with xdg-screensaver, caffeine-indicator would have to poll the state of the screensaver inhibition (although with freedesktop-compliant screensavers, such as KDE, GNOME, Cinnamon and MATE, it might be possible to be notified by DBus, I don't know).

I think Caffeine should work with a reasonable range of desktops, and to avoid becoming utterly horrible internally, it should defer to tools like xdg-screensaver (try looking at its code, it's a mess of special cases and duplication at present). I think xdg-screensaver should be the locus of further improvements in this area, because it can either be cleaned up (e.g. one might reasonably declare that it should only support desktops, hence support could be removed for non-desktop environments), and perhaps even reasonably modern desktops (this means it could support just xscreensaver and freedesktop, say); or it could continue to be highly backwards-compatible, but for example offer a way of being informed of the screensaver status (an extension of the current xdg-screensaver "status" command) which uses polling on systems where that's necessary, but otherwise does not impose that burden/imprecision on the calling program.

I'm afraid I don't have the time to work on this, but I'm very to advise on bug reports/design/code in xdg-screensaver that attempt to address these issues.

But as I say, the place to do most of the work (other than a simple indicator) is definitely upstream of Caffeine.


To further complicate things, systemd provides a similar interface for inhibition of power saving (and there are similar GNOME and KDE interfaces, using DBus or similar, too). One use of caffeinate is to prevent sleep during a system upgrade. For that to work well, one really wants to inhibit sleep, not the screensaver. However, if you're using caffeinate to stop the screensaver activating during a game or movie (clunky, but a handy workaround if your software doesn't already offer this functionality), then you really do want to inhibit the screensaver.

Changed in caffeine:
status: New → Won't Fix
Aaron Wolf (wolftune) wrote :

Thanks for all the thoughts. I wasn't holding out hope this would be easy, but figured the idea should at least be suggested in case it was doable.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers