4

I want to turn the screen off when inactive for x minutes using commandline settings on RHEL and Debian distros of Linux. Any help?

I have done this with the following commands on Ubuntu and Centos:

gsettings set org.gnome.desktop.session idle-delay 60
gsettings set org.gnome.desktop.screensaver lock-enabled true

How to do the same on RHEL & Debian? Any help appreciated.

  • There are two different concepts - turning on a screensaver and turning off a display using DPMS. What do you want? – Arkadiusz Drabczyk Apr 6 '15 at 10:51
  • @ArkadiuszDrabczyk, Anyone is fine for me – Suresh Kota Apr 6 '15 at 10:52
  • DPMS settings can be modified with xset command, see manpage. When it comes to screesaver, I am afraid that every screensaver out there has a separate config – Arkadiusz Drabczyk Apr 6 '15 at 11:00
  • Yeah, I have already tried xset commands. But those are not working – Suresh Kota Apr 6 '15 at 11:27
  • It works the same on every distribution. However it depends on your desktop environment. These settings apply to Gnome but not to other environments. What environment are you using on RHEL and Debian? You can use Gnome on these distributions, but apparently you're using something else, you need to tell us what. – Gilles 'SO- stop being evil' Apr 6 '15 at 22:57
7

Turning off screen after a specified period of inactivity can be achieved by at least 2 methods: either using xset DPMS features or a screensaver such as xscreensaver or gnome-screensaver.

Xset:

First, check whether your hardware supports DPMS:

$ xset dpms force standby

Your display should go blank. Apart from standby you can also try suspend and off. If you know that your HW supports DPMS you can tell xset to activate DPMS after a number of seconds (from man xset):

When numerical values are given, they set the inactivity period (in units of seconds) before the three modes are activated. The first value given is for the standby' mode, the second is for thesuspend' mode, and the third is for the `off' mode.

So, doing that will make your display go blank after 3 seconds of inactivity:

$ xset dpms 3 3 3

Run this command and wait for 3 seconds. This setting is not retained across reboots so if it works, you can add this line to your X startup script such as ~/.xinitrc or your window manager startup script. Notice that turning off a display with DPMS will not lock the screen, you need to use an external screensaver for that.

screensaver

There are many screensavers to choose from and most of them has their own config file that is independent of xset DPMS settings and can lock screens so that you need to know the password to unlock it. Some screensavers, however, may influence DPMS settings. For example, xscreensaver can override xset settings.

Unfortunately, I don't use gnome-screensaver and I have no idea what screensavers are installed by default on RHEL or Debian so I can't help you here but if you're looking for a nice screensaver give xscreensaver a try. If you also want to run some nice pictures it has a number of screensaver themes to choose from, it can display video files and is highly customizable. Modify lock setting in ~/.xscreensaver by hand or run xscreensaver-demo to set a period of inactivity after which a screensaver will lock the screen. After making this modification, run xscreensaver daemon command and wait to see if xscreensaver works correctly.

X screen saver

There is also an X in-built screensaver that can be activated with x set activate. Type xset q and see how long you will have to wait for it to start under Screen Saver section:

Screen Saver: prefer blanking: yes allow exposures: yes
timeout: 600 cycle: 600

In this case, you would have to wait for 600 seconds. Run it now:

$ xset s activate

If you set it with noblank flag, it will display a pattern set with xsetroot when activated:

$ xset s noblank
$ /usr/bin/xsetroot -solid Green
$ xset s activate

Disable it altogether:

$ xset s off
0

In my case the following worked:

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

gsettings set org.gnome.desktop.screensaver lock-enabled true

Debian 8

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.