Ubuntu – How to set a global timeout for the screensaver


I am trying to to set a global screensaver and blanking idle timout (with screen locking) that will affect all new user accounts. I noticed that gnome-screensaver in 12.04 when configured by a user, writes some data to a blob in ~/.dconf, but I have no idea how to set it globally. I also know that the global timeout is 10 minutes with blanking, but have no idea where this is set system wide. I find the whole dconf transition a bit difficult.

If it is not possible to configure gnome-screensaver this way, I would be quite interested in a solution with xscreensaver/xlock.

The purpose of this is to set a blank screen with automatic locking. Both because of resource usage and security.

Forgot to mention that this is a default Ubuntu 12.04 desktop install with Unity and LightDM. I will however install gnome-shell and gnome-session-fallback to let people choose. It would be nice if a solution works across different sessions.

Best Answer

Which dconf keys are used

To know which keys are changed in dconf, you can use dconf watch / while changing settings. In this case, you'll see something like :



  uint32 1800

Then, you put these keys in a file in /etc/dconf.

Create and activate /etc/dconf

If this directory does not exists, you have to create it and activate its use with these commands :

mkdir -p /etc/dconf/profile /etc/dconf/db/local.d
cat <<EOF >/etc/dconf/profile/user

cf: https://live.gnome.org/dconf/SystemAdministrators

Put your global settings

Use a file in /etc/dconf/db/local.d named, for example, screensaver-delay:



Apply it running the command: dconf update. It will (re)generate the file /etc/dconf/db/local which will be used if keys do not conflict with user defined values.

Force global values

If you want to force these global values over user selected values, you can do it by using a file in /etc/dconf/db/local.d/locks named, for example, screensaver-delay:

# Force screensaver delay