I recently upgraded from 14.04 Trusty to 16.04 Xenial. Prior to the upgrade, I used the caffeine-plus
indicator icon to tell the my laptop when it could sleep. The mode I normally used was to have Caffeine enabled so the computer would only sleep/suspend when the lid was closed. However, there were occasions when I wanted to be able to let the idle timer have its intended effect.
Since the upgrade, Caffeine doesn't appear to do anything anymore. I can leave my computer with a long-running process, deliberately keeping the lid open, only to come back to find it sleeping and the process unfinished.
How can I get the previous behavior back? Note that I'm looking for a toggle, not a permanent change. As a toggle, it should have a visual indication as to whether it's enabled or not. An indicator icon would be great.
Note
The searching I did prior to asking this question turned up either: a) old (outdated) posts about how to use Caffeine, or b) permanently disabling sleep to work around various hardware bugs. My question is simply about restoring the functionality I had in 14.04, a topic I didn't find addressed.
Edit
After a bit of work, I wrote up a more complete and easier-to-use solution than is found below. You can download the program on GitHub. You'll also need to install the dependencies:
Original Answer
After Jacob Vlijm pointed me toward a partial solution, I combined a modified version of his script with bits of Caffeine and some of my own code and came up with a replacement for Caffeine.
Instructions
Make sure the necessary packages are installed. Note:
caffeine-plus
is used only for icons. If you don't care about proper icons, you don't need it.Save the below script somewhere and make it executable.
Run the script.