59

I looking for a method to turn-off the screensaver and powermanager but from the command line.

I'm aware this can be done via the GUI screen - but can this be done via the command line or via some configuration editor?

Here is the gui way (via the "screen" or "brightness and lock" application):

enter image description here

Takkat
  • 142,284

11 Answers11

45

For 11.10

Disable the GNOME Settings Deamon's power plugin from the command line:

gsettings set org.gnome.settings-daemon.plugins.power active false

Alternatively, using dconf-editor from the dconf-tools package:

enter image description here

For the screensaver:

gsettings set org.gnome.desktop.screensaver idle-activation-enabled false

Or again via dconf-editor:

enter image description here

fossfreedom
  • 172,746
htorque
  • 64,798
  • 3
    This does not work. I have an HDMI monitor, and it still turns off after a few minutes. All screensaver and power settings seem to be completely ignored. – Cerin Feb 02 '13 at 23:51
  • 10
    For anyone that still trying to use this solution, this thing already deprecated as it's further description This key is deprecated and ignored. Set org.gnome.desktop.session idle-delay to 0 if you do not want to active the screensaver., try using the org.gnome.desktop.session idle-delay then. Just saying, hope can help. – ksugiarto Apr 30 '15 at 08:45
  • 1
    If the screen is turned off and goes into standby mode after some time, it might be related to the power management. Note that setting "Turn off after" to "Never" in Mate mate-power-preferences might not have any effect if Mate's power management isn't started when you log in. To check, open the autostart settings mate-session-properties and make sure the entry for mate-power-manager is enabled. – basic6 Feb 10 '20 at 22:19
  • Same for 20.04 LTS – Soheil Aug 19 '22 at 18:04
13

You might find that the above solution is necessary, but not sufficient. The screen might still be blanking after 10 minutes. This is a default setting compiled into Xorg.

To disabled it for the current session, run:

xset s off

You can put this in your .xsession file to disable it upon every login.

Thomas
  • 428
  • Where is the .xsession file located I couldn't find it, do I need to make one and if so where? – dginsd Jul 14 '13 at 20:16
  • The .xsession file is a hidden file in your Home directory. You can find it by pressing Ctrl+H. If you do not see the file, you can right-click and create the file with the name .xsession, or you can use your preferred text editor to make the file with the necessary info in it. – mstfacmly Jul 20 '13 at 20:14
8

You didn't specify if you want permanent solution or temporary solution. If you want to turn off screensaver and power management for e.g. 2 hours, you can simply inhibit those features.

In practice, you can simply run

systemd-inhibit sleep 2h

As an alternative, you may want to inhibit screensaver and power management until a given process has completed. For example,

systemd-inhibit wget "https://example.com/files/huge-download.dat"

would inhibit screensaver and power management until download has finished.

See man systemd-inhibit for more details. It allows you do disable only selected features and allows setting user visible string to explain why these features are inhibited (nice if your system has multiple users).

7

Make a plain text doc in your home folder and copy this into it.

#!/bin/bash
sleep 10 &&
xset s 0 0
xset s off
exit 0

Save the document as "screensaver_off.sh" (without quotes), then open a terminal and enter

chmod +x screensaver_off.sh

Then open up startup applications from the dash, click on the add button, name your start up application, and enter your command as:

"sh /home/$LOGNAME/screensaver_off.sh"

Then add a description and click add, reboot and your done, No more screen blanking.

You will have to do this per each user as default settings revert after logout or reboot.

enter image description here

dginsd
  • 601
  • 7
  • 9
4

After reading huge amounts of forum posts, I eventually managed to get rid of it by setting crontab to run every 4 minutes command:

DISPLAY=:0.0 xset s activate

you can leave DISPLAY=:0.0 out, if you have logged in with ssh as a same user which uses gnome.

xset s off didn't help in my case. I have to run that every 4 minutes, to prevent screen saver coming on every 5 minutes. :)

Takkat
  • 142,284
Tuipveus
  • 41
  • 1
3

You can go to System preferences. There is a program called "Brightnes and lock" (Im not shure how it is called in english. Look at my screenshot) In this menu you can define, when the screenlock is activatet.

enter image description here

Evenbit GmbH
  • 4,636
3

Here is a solution that worked for me .. The problem I had was as I upgraded my Ubuntu 12.04 to 12.10 and to Gnome 3.6 the screen went black when idle for like 5 minutes even if I did not have any conventional settings for an active screen saver, needless to say it was sickeningly annoying ..

Here is the solution I used and it worked (and I have tried a lot of different things, spending too much time searching on startpage.com (google)

Scroll down to 'No screensaver in GNOME 3.2'.

http://www.webupd8.org/2011/10/things-to-tweak-after-installing-ubuntu.html

3

Unchecking the "Dim screen to save power" is possible with

gsettings set org.gnome.settings-daemon.plugins.power idle-dim false

and setting the "Turn off after" to "Never" with

gsettings set org.gnome.desktop.session idle-delay 0

The last command was completely sufficient for my needs.

Mojo
  • 89
  • 5
2

Disabling Screensaver on Linux Environment from VNC Viewer enter image description here

Abhijeet
  • 121
1

Thomas answer above works, but not everyone has .xsession file. You can use your .profile instead. Just add the lines below to the end of the .profile in your Home folder.

# Turn off screen blanking xset s off && xset -dpms

If you don't see .profile, open your Home folder in your file browser, click on 'View' and select 'Show Hidden Files'. Then just right click on .profile, select 'Open with text editor', copy and paste the above on a blank line at the end of the file and save the modified file.

rjd
  • 69
0

I used dconf instead of gsettings which was readily available in Ansible.

Disable screensaver lock:

dconf write /org/gnome/desktop/screensaver/lock-enabled false

Read screensaver lock value:

dconf read /org/gnome/desktop/screensaver/lock-enabled