Chapter 16. Managing user sessions

16.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.

16.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 service forcibly interrupts any currently running GNOME session of any desktop user who is logged in. This can 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

16.3. Adding an autostart application for all users

To start an application automatically when any user logs in, create a .desktop file for that application in the /etc/xdg/autostart/ directory.

Procedure

  1. Create a .desktop file in the /etc/xdg/autostart/ directory:

    [Desktop Entry]
    Type=Application
    Name=Files
    Exec=nautilus -n
    OnlyShowIn=GNOME;
    AutostartCondition=GSettings org.gnome.desktop.background show-desktop-icons

    Replace Files with the name of the application.

    Replace nautilus -n with the command you want to use to run the application.

  2. Use the AutostartCondition key to check for a value of a GSettings key.

    The session manager runs the application automatically if the key’s value is true. If the key’s value changes in the running session, the session manager starts or stops the application, depending on what the previous value for the key was.

Additional resources

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

16.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.

16.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'

16.6. Setting screen brightness and idle time

This section describes how to:

  • 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.

16.7. 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.

16.8. 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.