Score:2

How to configure ScreenSaver by Command Line?

jp flag

I would like to configure ScreenSaver by command line (CLI) on Ubuntu MATE.

I am already familiar with the GUI to configure ScreenSaver on Ubuntu MATE 20.04 as shown below:

Control Center > Look and Feel >

  Screensaver

    Regard the computer as idle after:  2 hours

    [ ]  Activate screensaver when computer is idle
            /* I want to uncheck this */

    [ ]  Lock screen when screensaver is active
            /* I want to uncheck this */

By command line, I would like to configure ScreenSaver to the values shown above.

When configuring preferences in general, the following two points should be paid attention to.

  1. Whether the new values are effective only temporarily (the old values will be restored upon rebooting) or permanently (the new values will survive beyond rebooting).

  2. For permanent configuration, the new values need be saved to the disk. It is worth knowing how the values are stored on the disk. For a general example apart from ScreenSaver, the user information is stored in the configuration file "/etc/passwd", and his numerical user ID is stored in the third field on his record line in "/etc/passwd".

For the configuration of ScreenSaver, if a temporary method and a permanent method are available separately, then I would like to know both methods. For the permanent method, I would like to know how and where the new values are stored (perhaps, a key-value pair in a configuration file somewhere in the "/etc" directory?).

Score:3
zw flag

Basics

This options are usually saved using two tools - gsettings and dconf:

  • To get actual gsettings key names you need to run gsettings list-recursively > gs1 for first time and then change settings, then run it again gsettings list-recursively > gs2; then compare gs-files using meld gs1 gs2 to get a diff.
  • To monitor configuration changes in realtime you can run dconf watch / and then change some GUI options. Comparison of two shots is possible by running dconf dump / > dconf1 and dconf dump / > dconf2 and then using meld dconf1 dconf2 .

Per-user variant

Using gsettings

To set needed values for your current user permanently using gsettings you have to use commands below:

gsettings set org.mate.session idle-delay 120
gsettings set org.mate.screensaver idle-activation-enabled false
gsettings set org.mate.screensaver lock-enabled false

and reverting to defaults is possible by

gsettings set org.mate.session idle-delay 30
gsettings set org.mate.screensaver idle-activation-enabled true
gsettings set org.mate.screensaver lock-enabled true

Using dconf

To set them using dconf you can use

cat <<EOF | dconf load /
[org/mate/desktop/session]
idle-delay=120

[org/mate/screensaver]
idle-activation-enabled=false
lock-enabled=false
EOF

and reverting to defaults is possible by

cat <<EOF | dconf load /
[org/mate/desktop/session]
idle-delay=30

[org/mate/screensaver]
idle-activation-enabled=true
lock-enabled=true
EOF

System-wide dconf-based method

To set this options as defaults on system-wide level you have to run the following commands:

sudo mkdir -p /etc/dconf/profile

cat <<EOF | sudo tee /etc/dconf/profile/user
user-db:user
system-db:local
EOF

sudo mkdir -p /etc/dconf/db/local.d

cat <<EOF | sudo tee /etc/dconf/db/local.d/00-my
[org/mate/desktop/session]
idle-delay=120

[org/mate/screensaver]
idle-activation-enabled=false
lock-enabled=false
EOF

sudo dconf update

Reverting to defaults is possible by

sudo rm /etc/dconf/profile/user /etc/dconf/db/local.d/00-my
sudo dconf update

Consult with the following RedHat documentation for details:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.