Disabling the screensaver on Ubuntu 14.04
In Ubuntu Linux for some years there has been a great little utility to disable/enable the screensaver called caffeine. In the latest version the developer decided to remove the applet altogether from the tray. The application basically works in the background and detects if an application is in full screen or not.
But as seen in this discussion here there are many of us that relied on that simple way of manually turning on and off the screensaver quickly. The developer is unwilling to revert back to the previous functionality, which he/she is entitled to do so. I have found a round about way to supplement the current functionality of caffeine by using custom keyboard shortcuts.
There are two drawbacks to this method;
- The screensaver does not revert back to on upon reboot (may be a desired functionality for some use cases)
- There is still no indicator to tell you if it is disabled or not
Add the following to the command field: The “0” denotes zero seconds before the screen turns black, 0=never.
gsettings set org.gnome.desktop.session idle-delay 0
Highlight the new shortcut and then select your keyboard shortcut combination. I used the
Control key + the Win key + the letter “S”, but you can use what ever you like even “F” Keys.
But keep in mind that if that combination is already used in one of the other shortcuts, they will take precedence over your shortcut.
Now add another keyboard shortcut to enable the screensaver again, use the same command but change the number at the end to 600:
This will enable the screensaver back on at 10 minutes (10 X 60 seconds)
gsettings set org.gnome.desktop.session idle-delay 600
Now you MUST LOG OUT and log back in for it to take effect!
You can verify that it works by disabling the screensaver with your new shortcut then opening the System Settings> Brightness & Lock and then close the window. Then enable the screensaver and go back to Brightness & Lock and it should be enabled again.
As I noted above, if one forgets to turn the screen settings back on, this can be remedied by adding a simple shell script at login.
I recommend you create a directory in your home folder called “Scripts“, inside create a new document called “EnableScreen.sh“.
Open the new file and add the same code used for the keyboard shortcut and should look like the following:
#!/bin/bash gsettings set org.gnome.desktop.session idle-delay 600 exit 0
Save the document and make it Executable by right clicking on the file, go to properties and checking “Execute”.
Then open the “Startup Applications” from your Applications and add a new command to run the new script.
After you browse to the file from the command field, add “sh” at the beginning of the command. For example, my command looks looks like this:
So now, Caffeine will turn off the screen if any program goes into full screen mode, you can manually
turn on or off the screen but in case you forget, it will reset on next login, reboot is not required, only to login.
Someone should write a program that does this…sarcasm!
A fork of the original Caffeine 2.7 has been created which adds the deleted functionality.
The new project is called Caffeine Plus https://github.com/mildmojo/caffeine-plus
WEBUPD8 has a PPA for Cafeeine-plus