XScreenSaver(1) | General Commands Manual | XScreenSaver(1) |
xscreensaver - extensible screen saver and screen locking framework
xscreensaver [--display host:display.screen] [--verbose] [--version] [--no-splash] [--log filename]
XScreenSaver waits until the user is idle, and then runs graphics demos chosen at random. It can also lock your screen, and provides configuration and control of display power management.
XScreenSaver is also available on macOS, iOS and Android.
XScreenSaver is a daemon that runs in the background. You configure it with the xscreensaver-settings(1) program.
xscreensaver & xscreensaver-settings
When it is time to activate the screensaver, a full-screen black window is created that covers each monitor. A sub-process is launched for each one running a graphics demo, pointed at the appropriate window. Because of this, any program which can draw on a provided window can be used as a screensaver. The various graphics demos are, in fact, just standalone programs that do that.
When the user becomes active again, the screensaver windows are unmapped, and the running subprocesses are killed.
The display modes are run at a low process priority, and spend most of their time sleeping/idle by default, so they should not consume significant system resources.
The xscreensaver-settings(1) program is where you configure if and when your monitor should power off. It saves the settings in your ~/.xscreensaver file. Do not use xset(1) to manually change the power management settings, that won't work.
When the monitor is powered down, the display hacks will stop running (though it may take a minute or two for XScreenSaver to notice).
If your system uses systemd(1) or elogind(8), then closing the lid of your laptop will cause the screen to lock immediately.
If not, then the screen might not lock until a few seconds after you re-open the lid. Which is less than ideal. So if you do not have systemd(1), you might want to get in the habit of manually locking your screen before closing the lid (xscreensaver-command --lock).
Likewise, if you have systemd(1) or elogind(8), then all of the popular video players and web browsers will prevent XScreenSaver from blanking the screen while video is playing.
Both of these features require that xscreensaver-systemd(6) be able connect to D-Bus.
Each desktop environment has its own system for launching long-running daemons like XScreenSaver, and since many of them come bundled with their own (buggy, insecure, inferior) screen-locking frameworks, it is also necessary to disable those other frameworks before XScreenSaver can work.
For many years, GNOME included XScreenSaver as-is, and everything just worked. Not any more!
sudo apt remove gnome-screensaver sudo apt remove mate-screensaver sudo apt remove cinnamon-screensaver sudo apt remove light-locker or sudo rpm -e gnome-screensaver sudo rpm -e mate-screensaver sudo rpm -e cinnamon-screensaver sudo rpm -e light-lockerBe careful that it doesn't try to uninstall all of GNOME.
"Settings / Privacy / Screen Lock / Blank Screen
Delay"
"Settings / Privacy / Screen Lock / Automatic Screen
Lock"
"Settings / Power / Blank Screen"
"Settings / Power / Automatic Suspend"
Or, see the "LAUNCHING XSCREENSAVER FROM SYSTEMD" section below. That works too.
sudo ln -sf /usr/bin/xscreensaver-command \ /usr/bin/gnome-screensaver-command sudo ln -sf /usr/bin/xscreensaver-command \ /usr/bin/cinnamon-screensaver-command sudo ln -sf /usr/bin/xscreensaver-command \ /usr/bin/mate-screensaver-command sudo ln -sf /usr/bin/xscreensaver-command \ /usr/bin/xfce4-screensaver-command sudo ln -sf /usr/bin/xscreensaver-command \ /usr/bin/light-locker-commandThis change will get blown away when you upgrade.
Like GNOME, KDE also decided to re-invent the wheel. To replace the KDE screen saver with XScreenSaver, do the following:
"Workspace Behavior / Screen Locking / Lock
automatically"
"Workspace Behavior / Screen Locking / After waking from
sleep"
"Workspace Behavior / Screen Locking / Keyboard shortcut"
"Hardware / Power Management / Screen Energy Saving"
"Hardware / Power Management / Suspend session"
"Hardware / Power Management / Laptop lid closed" = Do
Nothing
If there are multiple tabs, you may need to change these settings on all three of them: "On AC power", "Battery" and "Low Battery".
#!/bin/sh xscreensaver-command --lock &This change will get blown away when you upgrade.
kwriteconfig5 --file startkderc --group General \ --key systemdBoot trueLog out and back in.
Next, edit the plasma-ksmserver service to change how ksmserver is launched:
systemctl edit --user plasma-ksmserver.serviceReplace the contents of the file that lets you edit with this:
[Service] ExecStart= ExecStart=/usr/bin/ksmserver --no-lockscreenThen log out and back in again.
Add the line @xscreensaver to /etc/xdg/lxsession/LXDE/autostart or /etc/xdg/lxsession/LXDE-pi/autostart.
If you are not using GNOME, KDE or LXDE, the way to launch XScreenSaver at login is probably systemd(1).
Copy the file /usr/share/xscreensaver/xscreensaver.service into the directory ~/.config/systemd/user/. Create that directory first if it doesn't exist. Then enable it with:
systemctl --user enable xscreensaver
If you are not using GNOME, KDE or LXDE, and your system uses upstart(7) instead of systemd(1), launch the "Startup Applications" applet, click "Add", and enter these lines:
Name: XScreenSaver Command: xscreensaver Comment: XScreenSaver
BSD systems or other systems without systemd(1) or elogind(8) might have luck by adding "xscreensaver-command --suspend" to some appropriate spot in /etc/acpi/events/anything or in /etc/acpi/handler.sh, if those files exist.
You can run xscreensaver from your gdm(1) session, so that the screensaver will run even when nobody is logged in on the console. To do this, run gdmconfig(1).
On the General page set the Local Greeter to Standard Greeter.
On the Background page, type the command "xscreensaver --no-splash" into the Background Program field. That will cause gdm to run XScreenSaver while nobody is logged in, and kill it as soon as someone does log in. (The user will then be responsible for starting XScreenSaver on their own, if they want.)
If that doesn't work, you can edit the config file directly. Edit /etc/X11/gdm/gdm.conf to include:
Greeter=/usr/bin/gdmlogin BackgroundProgram=xscreensaver --no-splash RunBackgroundProgramAlways=trueIn this situation, the xscreensaver process will be running as user gdm. You can configure the settings for this nobody-logged-in state (timeouts, DPMS, etc.) by editing the ~gdm/.xscreensaver file.
If you get "connection refused" errors when running xscreensaver from gdm, then this probably means that you are having xauth(1) problems. For information on the X server's access control mechanisms, see the man pages for X(1), Xsecurity(1), xauth(1), and xhost(1).
There might be a way to accomplish this with other display managers. It's a mystery!
Wayland is a completely different window system that is intended to replace X11. After 14+ years of trying, some Linux distros have finally begun enabling it by default. Most deployments of it also include XWayland, which is a compatibility layer that allows some X11 programs to continue to work within a Wayland environment.
Unfortunately, XScreenSaver is not one of those programs.
If your system is running XWayland, XScreenSaver will malfunction in two ways:
This means that while a native Wayland program is selected, XScreenSaver will think that you are idle, and may blank the screen prematurely.
This is because X11 grabs don't work properly under XWayland, so there is no way for XScreenSaver to prevent the user from switching away from the screen locker to another application.
In short, for XScreenSaver to work properly, you will need to switch off Wayland and use the X Window System like in the "good old days".
The login screen should have a gear-icon menu that lets you change the session type from "GNOME" (the Wayland session) to "GNOME on Xorg" (the X11 session).
Alternately, edit /etc/gdm/custom.conf and make sure it includes this line:
WaylandEnable=false
The login screen should have a menu that lets you change the session type to "Plasma (X11)".
Alternately, edit /etc/sddm.conf and change the SessionDir line under the [Wayland] section to say:
SessionDir=/dev/null
XScreenSaver has a decades-long track record of securely locking your screen. However, there are many things that can go wrong. X11 is a very old system, and has a number of design flaws that make it susceptible to foot-shooting.
The Xorg and XFree86 X servers, as well as the Linux kernel, both trap certain magic keystrokes before X11 client programs ever see them. If you care about keeping your screen locked, this is a big problem.
There is no way to disable VT switching only when the screen is locked. It's all or nothing.
echo 176 > /proc/sys/kernel/sysrqThere's little that I can do to make the screen locker be secure so long as the kernel and X11 developers are actively working against security like this. The strength of the lock on your front door doesn't matter much so long as someone else in the house insists on leaving a key under the welcome mat.
Even if you have disabled the Alt-SysRq-F OOM-killer keystroke, the OOM-killer might still decide to assassinate XScreenSaver at random, which will unlock your screen. If the xscreensaver-auth(6) program is installed setuid, it attempts to tell the OOM-killer to leave the XScreenSaver daemon alone, but that may or may not work.
You would think that the OOM-killer would pick the process using the most memory, but most of the time it seems to pick the process that would be most comically inconvenient, such as your screen locker, or crond(8). You can disable the OOM-killer entirely with:
echo 2 > /proc/sys/vm/overcommit_memory echo vm.overcommit_memory = 2 >> /etc/sysctl.confIn addition to the kernel's OOM-killer, systemd(1) has its own. The included xscreensaver.service file attempts to evade it, but you may want to just turn it off anyway:
sudo systemctl disable --now systemd-oomd sudo systemctl mask systemd-oomd
X11's security model is all-or-nothing. If a program can connect to your X server at all, either locally or over the network, it can log all of your keystrokes, simulate keystrokes, launch arbitrary programs, and change the settings of other programs. Assume that anything that can connect to your X server can execute arbitrary code as the logged-in user. See Xsecurity(1) and xauth(1).
If your system uses PAM (Pluggable Authentication Modules), then PAM must be configured for XScreenSaver. If it is not, then you might be in a situation where you can't unlock. Probably the file you need is /etc/pam.d/xscreensaver.
Never log in as root. Log in as a normal user and use sudo(1) as necessary. If you are logged in as root, XScreenSaver will not lock your screen or run display modes, for numerous good and proper reasons.
For a single user, the proper way to configure XScreenSaver is to simply run the xscreensaver-settings(1) program, and change the settings through the GUI. Changes are written to the ~/.xscreensaver file.
If you want to set the system-wide defaults, then make your edits to /etc/X11/app-defaults/XScreenSaver instead. The two files have similar (but not identical) syntax.
You can also make changes via the X Resource Database and xrdb(1), but that can be very confusing and is not really recommended.
Options in ~/.xscreensaver override any settings in the resource database or app-defaults file.
If you change a setting in the .xscreensaver file while XScreenSaver is already running, it will notice this, and reload the file as needed. But if you change a setting in the X Resource Database, you will need to restart XScreenSaver for those changes to take effect:
xrdb < ~/.Xdefaults xscreensaver-command --restart
These are the X resources use by XScreenSaver program. You probably won't need to change these manually: that's what the xscreensaver-settings(1) program is for.
If there are multiple screens, the savers are staggered slightly so that while they all change every cycle minutes, they don't all change at the same time.
When the screensaver starts up, one of these is selected (according to the mode setting), and run. After the cycle period expires, it is killed, and another is selected and run.
If a line begins with a dash (-) then that particular program is disabled: it won't be selected at random (though you can still select it explicitly using the xscreensaver-settings(1) program).
If all programs are disabled, then the screen will just be made blank, as when mode is set to blank.
To disable a program, you must mark it as disabled with a dash instead of removing it from the list. This is because the system-wide (app-defaults) and per-user (.xscreensaver) settings are merged together, and if a user just deletes an entry from their programs list, but that entry still exists in the system-wide list, then it will come back. However, if the user disables it, then their setting takes precedence.
The default XScreenSaver hacks directory (typically /usr/libexec/xscreensaver/) is prepended to $PATH before searching for these programs.
To use a program as a screensaver, it must be able to render onto the window provided to it in the $XSCREENSAVER_WINDOW environment variable. If it creates and maps its own window instead, it won't work. It must render onto the provided window.
Visuals:
Because XScreenSaver was created back when dinosaurs roamed the earth, it still contains support for some things you've probably never seen, such as 1-bit monochrome monitors, grayscale monitors, and monitors capable of displaying only 8-bit colormapped images.
If there are some programs that you want to run only when using a color display, and others that you want to run only when using a monochrome display, you can specify that like this:
mono: mono-program -root \n\ color: color-program -root \n\More generally, you can specify the kind of visual that should be used for the window on which the program will be drawing. For example, if one program works best if it has a colormap, but another works best if it has a 24-bit visual, both can be accommodated:
PseudoColor: cmap-program -root \n\ TrueColor: 24bit-program -root \n\In addition to the symbolic visual names described above (in the discussion of the visualID resource) one other visual name is supported in the programs list:
If you specify a particular visual for a program, and that visual
does not exist on the screen, then that program will not be chosen to run.
This means that on displays with multiple screens of different depths, you
can arrange for appropriate hacks to be run on each. For example, if one
screen is color and the other is monochrome, hacks that look good in mono
can be run on one, and hacks that only look good in color will show up on
the other.
Specify which X visual to use by default. (Note carefully that this resource is called visualID, not merely visual; if you set the visual resource instead, things will malfunction in obscure ways for obscure reasons.)
Valid values for the VisualID resource are:
Note that this option specifies only the default visual that will be used: the visual used may be overridden on a program-by-program basis. See the description of the programs resource, above.
This does nothing if you have a TrueColor (16-bit or deeper) display. (Which, in this century, you do.)
A single pixel of motion will still cause the monitor to power back on, but not un-blank. This is because the X11 server itself unfortunately handles power-management-related activity detection rather than XScreenSaver.
https://www.jwz.org/xscreensaver/bugs.html explains how to write the most useful bug reports. If you find a bug, please let me know!
The latest version of XScreenSaver, an online version of this manual, and a FAQ can always be found at https://www.jwz.org/xscreensaver/
X(1), Xsecurity(1), xauth(1), xdm(1), gdm(1), xhost(1), systemd(1), elogind(8), xscreensaver-settings(1), xscreensaver-command(1), xscreensaver-systemd(6), xscreensaver-gl-helper(6), xscreensaver-getimage(6), xscreensaver-text(6).
Copyright © 1991-2022 by Jamie Zawinski. Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. No representations are made about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.
Jamie Zawinski <jwz@jwz.org>
Please let me know if you find any bugs or make any improvements.
And a huge thank you to the hundreds of people who have contributed, in large ways and small, to the XScreenSaver collection over the past three decades!
6.09 (07-Jun-2024) | X Version 11 |