Stop screensaver and lock session on Debian by command line

28,264

Solution 1

Some background

First, let's pick apart what you've tried.

The commands

xset -dpms

and

xset s off

control the X Server (the piece of software actually responsible for presenting you with a graphical display and managing input devices on it, such as mouse) directly, while

setterm -powersave off

is meant only for what are called "virtual consoles" in Linux ("term" there comes from the word "terminal", and Linux virtual consoles emulate terminals; let's not dig deeper for now). These are those "scary" text-only interfaces which you see when you press Ctrl+Alt+Fn (where n is 1 to 6, typically); use Alt+F7 there to switch back to X.

But you are not using the X server directly. Instead, what you interact with is the so-called "desktop environment" (DE)—a set of programs responsible for actually presenting you with windows, ways to manage them and other stuff you expect to be available (like system menu for logging off / rebooting / the clock etc). The DE itself controls the X server and that's why your attempts at using xset were in vain.

Debian ships many DEs (GNOME, KDE, XFCE, LXDE to name a few) and they have different appearances, settings etc. By default, Debian 7 installs GNOME, specifically, GNOME 3 (GNOME 3 received a major redesign since the 2.x series provoking both many praises and curses).

Consequently, when you use a dialog called "System settings", that's not really system settings (in a literal sense) but rather GNOME's system settings. So really when you're googling for screensaver problems "in Debian" you should better search for GNOME 3 screensaver problems.

What to do

Switching off automatic screen blanking (built-in screensaver)

GNOME project adopted a policy of constantly dumbing down the setting dialogs so I reckon they've just thought you wouldn't ever need to turn off screen blanking.

The solution is to install the so-called "GNOME Tweak Tool"—an external program wich allows tweaking settings not made available by GNOME's native dialogs.

Use

# apt-get install gnome-tweak-tool

(or whatever method you're using to install packages) to install it and then run it and tweak the screensaver settings however you wish.

Manually locking the screen

Contrary to, say, Windows, where the screensaver is a part of "the shell" (called Explorer), under GNOME (and most other desktop environments or window managers in the GNU/Linux land) screen locking is done by a separate program, and Debian ships many of them.

So you have to:

  1. Find out what screensaver program you have at hand;

    You most probably have the gnome-screensaver package installed which provides the /usr/bin/gnome-screensaver-command program.

  2. Bind some key combination in GNOME to ru it.

    This one is trickier. You have to use the keyboard preferences configuration dialog and pick a key combo to run that program.

    Google tells me in GNOME this dialog is located in "System Settings" → "Keyboard" → "Shortcuts".

    First, check to see if that dialog already contains an entry for "screen saver" or "screen locking" of something like that. If so, just learn the shortcut or pick your own and set it. Win+l might be a good pick—just like in Windows (and I personally prefer Win+Pause).

    If there's no pre-cooked entry for locking the screen, add a custom one—running the program we've already discussed.

More info here and elsewhere on the internets—just google for GNOME+screensaver.

Solution 2

This works for me on Debian 9:

gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-timeout 0
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 0
gsettings set org.gnome.desktop.session idle-delay 0
Share:
28,264

Related videos on Youtube

brcebn
Author by

brcebn

Updated on September 18, 2022

Comments

  • brcebn
    brcebn over 1 year

    I tried several ways to stop the screensaver and the lock session but I can't fix it.

    I went to the settings but there isn't any "never" for the screensaver timer. The minimum is 1 minute, the maximum 1 hour. System Settings > Power Management .. I didn't find the solution of this issue.

    I tried xset -dpms xset s off and setterm -powersave off (but I have a argument error).

    Nothing works.

    Does anyone have an idea?

    I'm with Debian 7 after a PXE installation on a Gigabytes Brix 2955.

    Thank you in advance.

  • brcebn
    brcebn over 9 years
    You were right. I searched with Gnome 3 and I found these command lines. gsettings set org.gnome.settings-daemon.plugins.power sleep-display-ac 0 gsettings set org.gnome.settings-daemon.plugins.power sleep-display-battery 0 gsettings set org.gnome.desktop.session idle-delay 0. Everything is fine. Thank you!