58

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

0

11 Answers 11

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

4
  • 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 2, 2013 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, 2015 at 8: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, 2020 at 22:19
  • Same for 20.04 LTS
    – Soheil
    Aug 19, 2022 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.

2
  • Where is the .xsession file located I couldn't find it, do I need to make one and if so where?
    – dginsd
    Jul 14, 2013 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, 2013 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

5
  • 2
    Why sleep 10?
    – Dirk
    Oct 7, 2015 at 19:01
  • 1
    Sleep 10 allows all your xserver and desktop environment to load, on a better, faster computer a lower number could be used, this is what worked on mine. I'm sure there's a more efficient and proper way to do this, I just don't know it.
    – dginsd
    Sep 29, 2016 at 13:14
  • Why the && after the sleep? Aug 11, 2020 at 10:09
  • You should do any "sleep" in the background.
    – ceving
    Jan 26, 2023 at 8:11
  • && doesn't put stuff in the background – it's logical and operator in shells. Apr 10, 2023 at 9:48
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. :)

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

2
  • In US English it is "Brightness and Lock", as you suggest.
    – david6
    Jun 28, 2012 at 5:01
  • That's not the issue, blank screen still appears over movies and full screen youtube clips.
    – Xamidovic
    Aug 16, 2012 at 5:36
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

1
  • 2
    Welcome to Ask Ubuntu! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. Oct 21, 2012 at 13:42
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.

2

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

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.

2
  • .profile gets executed even if no X is running. That is the wrong place.
    – ceving
    Jan 26, 2023 at 8:16
  • 1
    Arch-Linux-Wiki says that you can do it both at once: xset s off -dpms
    – ceving
    Jan 26, 2023 at 8:18
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .