Chapter 21. Managing user sessions

21.1. What GDM is

The GNOME Display Manager (GDM) is a graphical login program running in the background that runs and manages the X.Org display servers for both local and remote logins.

GDM is a replacement for XDM, the X Display Manager. However, GDM is not derived from XDM and does not contain any original XDM code. In addition, there is no support for a graphical configuration tool in GDM, so editing the /etc/gdm/custom.conf configuration file is necessary to change the GDM settings.

21.2. Restarting GDM

When you make changes to the system configuration such as setting up the login screen banner message, login screen logo, or login screen background, restart GDM for your changes to take effect.

Warning

Restarting the gdm service terminates all currently running GNOME sessions of all desktop users who are logged in. This might result in users losing unsaved data.

Procedure

  • To restart the GDM service, run the following command:

    # systemctl restart gdm.service

Procedure

  • To display results of the GDM configuration, run the following command:

    $ DCONF_PROFILE=gdm gsettings list-recursively org.gnome.login-screen

21.3. Adding an autostart application for all users

You can set application to start automatically when any user logs into the GNOME environment.

Procedure

  1. Create a .desktop file in the /etc/xdg/autostart/ directory, such as /etc/xdg/autostart/nautilus.desktop. Enter the following content in the file:

    [Desktop Entry]
    Type=Application
    Name=Files
    Exec=/usr/bin/nautilus -n
    OnlyShowIn=GNOME;
    X-GNOME-Autostart-enabled=true
    • Replace Files with the name of the application.
    • Replace /usr/bin/nautilus -n with the command that starts the application. Use the full file path.
  2. Optionally, configure the application to start only when a selected GSettings key is enabled. GNOME then runs the application automatically if the key’s value is true. If the key’s value changes in the running session, GNOME starts or stops the application to match the new value.

    Add the following line in the .desktop file:

    AutostartCondition=GSettings org.gnome.desktop.background show-desktop-icons
    • Replace org.gnome.desktop.background show-desktop-icons with the GSettings schema and key that the automatic start depends on.

Additional resources

  • You can also configure an autostart application for a specific user. Use the Tweaks application, which is available from the gnome-tweaks package.

21.4. Configuring automatic login

As an administrator, you can enable automatic login from the Users panel in GNOME Settings, or you can set up automatic login manually in the GDM custom configuration file, as follows.

Run the following procedure to set up automatic login for a user john.

Procedure

  • Edit the /etc/gdm/custom.conf file, and make sure that the [daemon] section in the file specifies the following:

    [daemon]
    AutomaticLoginEnable=True
    AutomaticLogin=john

    Replace john with the user that you want to be automatically logged in.

21.5. Configuring automatic logout

User sessions that have been idle for a specific period of time can be ended automatically. You can set different behavior based on whether the machine is running from a battery or from mains power by setting the corresponding GSettings key, then locking it.

Warning

Users can potentially lose unsaved data if an idle session is automatically ended.

To set automatic logout for a mains powered machine:

Procedure

  1. Create a local database for machine-wide settings in the /etc/dconf/db/local.d/00-autologout file:

    [org/gnome/settings-daemon/plugins/power]
    # Set the timeout to 900 seconds when on mains power
    sleep-inactive-ac-timeout=900
    # Set action after timeout to be logout when on mains power
    sleep-inactive-ac-type='logout'
  2. Override the user’s setting, and prevent the user from changing it in the /etc/dconf/db/local.d/locks/autologout file:

    # Lock automatic logout settings
    /org/gnome/settings-daemon/plugins/power/sleep-inactive-ac-timeout
    /org/gnome/settings-daemon/plugins/power/sleep-inactive-ac-type
  3. Update the system databases:

    # dconf update
  4. Users must log out and back in again before the system-wide settings take effect.

The following GSettings keys are of interest:

  • org.gnome.settings-daemon.plugins.power.sleep-inactive-ac-timeout

    The number of seconds that the computer needs to be inactive before it goes to sleep if it is running from AC power.

  • org.gnome.settings-daemon.plugins.power.sleep-inactive-ac-type

    What should happen when the timeout has passed if the computer is running from AC power.

  • org.gnome.settings-daemon.plugins.power.sleep-inactive-battery-timeout

    The number of seconds that the computer needs to be inactive before it goes to sleep if it is running from power.

  • org.gnome.settings-daemon.plugins.power.sleep-inactive-battery-type

    What should happen when the timeout has passed if the computer is running from battery power.

If you want to list available values for a key, use the following procedure:

Procedure

  • Run the gsettings range command on the required key. For example:
$ gsettings range org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type
enum
'blank'
'suspend'
'shutdown'
'hibernate'
'interactive'
'nothing'
'logout'

21.6. Setting a default desktop session for all users

You can configure a default desktop session that is preselected for all users that have not logged in yet.

If a user logs in using a different session than the default, their selection persists to their next login.

Procedure

  1. Copy the configuration file template:

    # cp /usr/share/accountsservice/user-templates/standard \
         /etc/accountsservice/user-templates/standard
  2. Edit the new /etc/accountsservice/user-templates/standard file. On the Session=gnome line, replace gnome with the session that you want to set as the default.
  3. Optional: To configure an exception to the default session for a certain user, follow these steps:

    1. Copy the template file to /var/lib/AccountsService/users/user-name:

      # cp /usr/share/accountsservice/user-templates/standard \
           /var/lib/AccountsService/users/user-name
    2. In the new file, replace variables such as ${USER} and ${ID} with the user values.
    3. Edit the Session value.

21.7. Setting screen brightness and idle time

By creating a local database, you can, for example:

  • Configure the drop in the brightness level
  • Set brightness level
  • Set idle time

Configuring the drop in the brightness level

To set the drop in the brightness level when the device has been idle for some time:

Procedure

  1. Create a local database for machine-wide settings in the /etc/dconf/db/local.d/00-power file including these lines:

    [org/gnome/settings-daemon/plugins/power]
    idle-dim=true
  2. Update the system databases:

    # dconf update
  3. Users must log out and back in again before the system-wide settings take effect.

Setting brightness level

To set brightness level:

Procedure

  1. Create a local database for machine-wide settings in the /etc/dconf/db/local.d/00-power file, as in the following example:

    [org/gnome/settings-daemon/plugins/power]
    idle-brightness=30

    Replace 30 with the integer value you want to use.

  2. Update the system databases:

    # dconf update
  3. Users must log out and back in again before the system-wide settings take effect.

Setting idle time

To set idle time after which the screen is blanked and the default screensaver is displayed:

Procedure

  1. Create a local database for machine-wide settings in /etc/dconf/db/local.d/00-session, as in the following example:

    [org/gnome/desktop/session]
    idle-delay=uint32 900

    Replace 900 with the integer value you want to use.

    You must include the uint32 along with the integer value as shown.

  2. Update the system databases:

    # dconf update
  3. Users must log out and back in again before the system-wide settings take effect.

21.8. Locking the screen when the user is idle

To enable the screensaver and make the screen lock automatically when the user is idle, follow this procedure:

Procedure

  1. Create a local database for system-wide settings in the etc/dconf/db/local.d/00-screensaver file:

    [org/gnome/desktop/session]
    # Set the lock time out to 180 seconds before the session is considered idle
    idle-delay=uint32 180
    [org/gnome/desktop/screensaver]
    # Set this to true to lock the screen when the screensaver activates
    lock-enabled=true
    # Set the lock timeout to 180 seconds after the screensaver has been activated
    lock-delay=uint32 180

    You must include the uint32 along with the integer key values as shown.

  2. Override the user’s setting, and prevent the user from changing it in the /etc/dconf/db/local.d/locks/screensaver file:

    # Lock desktop screensaver settings
    /org/gnome/desktop/session/idle-delay
    /org/gnome/desktop/screensaver/lock-enabled
    /org/gnome/desktop/screensaver/lock-delay
  3. Update the system databases:

    # dconf update
  4. Users must log out and back in again before the system-wide settings take effect.

21.9. Screencast recording

GNOME Shell features a built-in screencast recorder. The recorder allows users to record desktop or application activity during their session and distribute the recordings as high-resolution video files in the webm format.

To make a screencast:

Procedure

  1. To start the recording, press the Ctrl+Alt+Shift+R shortcut.

    When the recorder is capturing the screen activity, it displays a red circle in the top-right corner of the screen.

  2. To stop the recording, press the Ctrl+Alt+Shift+R shortcut.

    The red circle in the top-right corner of the screen disappears.

  3. Navigate to the ~/Videos directory where you can find the recorded video with a file name that starts with Screencast and includes the date and time of the recording.
Note

The built-in recorder always captures the entire screen, including all monitors in multi-monitor setups.