Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

14.3. User Sessions

14.3.1. What Are Typical Processes in User Sessions?

In a stock GNOME session, programs called daemons run on the system as background processes. You should find the following daemons running by default:
dbus-daemon
The dbus-daemon provides a message bus daemon which programs can use to exchange messages with one another. dbus-daemon is implemented with the D-Bus library which provides one-to-one communication between any two applications.
For extended information, see the dbus-daemon(1) man page.
gnome-keyring-daemon
Credentials such as user name and password for various programs and websites are stored securely using the gnome-keyring-daemon. This information is written into an encrypted file called the keyring file and saved in the user's home directory.
For extended information, see the gnome-keyring-daemon(1) man page.
gnome-session
The gnome-session program is responsible for running the GNOME Desktop environment with help of a display manager, such as GDM. The default session for the user is set at the time of system installation by the system administrator. gnome-session typically loads the last session that ran successfully on the system.
For extended information, see the gnome-session(1) man page.
gnome-settings-daemon
The gnome-settings-daemon handles settings for a GNOME session and for all programs that are run within the session.
For extended information, see the gnome-settings-daemon(1) man page.
gnome-shell
gnome-shell provides the core user interface functionality for GNOME, such as launching programs, browsing directories, viewing files and so on.
For extended information, see the gnome-shell(1) man page.
pulseaudio
PulseAudio is a sound server for Red Hat Enterprise Linux that lets programs output audio using the Pulseaudio daemon.
For extended information, see the pulseaudio(1) man page.
Depending on the user's setup, you may also see some of the following, among others:
  • dconf-service
  • ibus
  • at-spi2-dbus-launcher
  • at-spi2-registryd
  • gnome-shell-calendar-server
  • goa-daemon
  • gsd-printer
  • various Evolution factory processes
  • various GVFS processes

14.3.2. Configuring a User Default Session

The default session is retrieved from a program called AccountsService. AccountsService stores this information in the /var/lib/AccountsService/users/ directory.

Note

In GNOME 2, the .dmrc file in the user home directory was used to create default sessions. This .dmrc file is no longer used.

Procedure 14.5. Specifying a Default Session for a User

  1. Make sure that you have the gnome-session-xsession package installed by running the following command:
    # yum install gnome-session-xsession
  2. Navigate to the /usr/share/xsessions directory where you can find .desktop files for each of the available sessions. Consult the contents of the .desktop files to determine the session you want to use.
  3. To specify a default session for a user, update the user's account service in the /var/lib/AccountsService/users/username file:
    [User]
    Language=
    XSession=gnome
    In this sample, GNOME has been set as the default session, using the /usr/share/xsessions/gnome.desktop file. Note that the system default in Red Hat Enterprise Linux 7 is GNOME Classic (the /usr/share/xsessions/gnome-classic.desktop file).
After specifying a default session for the user, that session will be used the next time the user logs in, unless the user selects a different session from the login screen.

14.3.3. Creating a Custom Session

To create your own session with customized configuration, follow these steps:
  1. Create a .desktop file in /etc/X11/sessions/new-session.desktop. Make sure that the file specifies the following entries:
    [Desktop Entry]
    Encoding=UTF-8
    Type=Application
    Name=Custom Session
    Comment=This is our custom session
    Exec=gnome-session --session=new-session
    The Exec entry specifies the command, possibly with arguments, to execute. You can run the custom session with the gnome-session --session=new-session command.
    For more information on the parameters that you can use with gnome-session, see the gnome-session(1) man page.
  2. Create a custom session file in /usr/share/gnome-session/sessions/new-session.session where you can specify the name and required components for the session:
    [GNOME Session]
    Name=Custom Session
    RequiredComponents=gnome-shell-classic;gnome-settings-daemon;
    Note that any item that you specify in RequiredComponents needs to have its corresponding .desktop file in /usr/share/applications/.
After configuring the custom session files, the new session will be available in the session list on the GDM login screen.

14.3.4. Viewing User Session Logs

If you want to find more information about a problem in a user session, you can view the systemd journal. Because Red Hat Enterprise Linux 7 is a systemd-based system, the user session log data is stored directly in the systemd journal in a binary format.

Note

In Red Hat Enterprise Linux 6, the user session log data was stored in the ~/.xsession-errors file, which is no longer used.

Procedure 14.6. Viewing User Session Logs

  1. Determine your user ID (uid) by running the following command:
    $ id --user
    1000
  2. View the journal logs for the user ID determined above:
    $ journalctl _UID=1000

Getting More Information

The journalctl(1) man page provides more information on the systemd journal usage.
For further information about using the systemd journal on Red Hat Enterprise Linux 7, see the Red Hat Enterprise Linux 7 System-Level Authentication Guide.

14.3.5. Adding an Autostart Application for All Users

To start an application automatically when the user logs in, you need to create a .desktop file for that application in the /etc/xdg/autostart/ directory.
To manage autostart (startup) applications for individual users, use the gnome-session-properties application.

Procedure 14.7. Adding an Autostart (Startup) Application for All Users

  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
  2. Replace Files with the name of the application.
  3. Replace nautilus -n with the command you wish to use to run the application.
  4. You can 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.

14.3.6. Configuring Automatic Login

A user with an Administrator account type can enable Automatic Login from the Users panel in the GNOME Settings. System administrators can also set up automatic login manually in the GDM custom configuration file, as follows.

Example 14.1. Configuring Automatic Login for a user john

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.

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

Keep in mind that users can potentially lose unsaved data if an idle session is automatically ended.

Procedure 14.8. Setting Automatic Logout for a Mains Powered Machine

  1. Create a local database for machine-wide settings in /etc/dconf/db/local.d/00-autologout:
    [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 /etc/dconf/db/local.d/locks/autologout:
    # 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.
You can run the gsettings range command on a key for a list of values which you can use. For example:
$ gsettings range org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type
enum
'blank'
'suspend'
'shutdown'
'hibernate'
'interactive'
'nothing'
'logout'

14.3.8. Setting Screen Brightness and Idle Time

By setting the following GSettings keys, you can configure the drop in the brightness level, and set brightness level and idle time.

Example 14.2. Setting the Drop in the Brightness Level

To set the drop in the brightness level when the device has been idle for some time, create a local database for machine-wide settings in /etc/dconf/db/local.d/00-power, as in the following example:
[org/gnome/settings-daemon/plugins/power]
idle-dim=true

Example 14.3. Setting Brightness Level

To change the brightness level, create a local database for machine-wide settings in /etc/dconf/db/local.d/00-power, as in the following example, and replace 30 with the integer value you want to use:
[org/gnome/settings-daemon/plugins/power]
idle-brightness=30

Example 14.4. Setting Idle Time

To set the idle time after which the screen must be blanked and the default screensaver displayed, create a local database for machine-wide settings in /etc/dconf/db/local.d/00-session, as in the following example, and replace 900 with the integer value you want to use:
[org/gnome/desktop/session]
idle-delay=uint32 900
You must include the uint32 along with the integer value as shown.
Incorporate your changes into the system databases by running the dconf update command as root.
Users must log out and back in again before the system-wide settings take effect.

Note

You can also lock down the above settings to prevent users from changing them. For more information about locks, see Section 9.5.1, “Locking Down Specific Settings”.

14.3.9. Locking the Screen When the User Is Idle

If you want to enable the screensaver and make the screen lock automatically when the user is idle, you need to create a dconf profile, set the GSettings key pairs and then lock it to prevent users from editing it.

Procedure 14.9. Enabling the Screensaver and Locking the Screen

  1. Create a local database for system-wide settings in /etc/dconf/db/local.d/00-screensaver:
    [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.

14.3.10. Screencast Recording

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

Procedure 14.10. Making a Screencast

  1. To start the recording, press Ctrl+Alt+Shift+R.
    When the recorder is capturing the screen activity, it displays a red circle in the bottom-right corner of the screen.
  2. To stop the recording, press Ctrl+Alt+Shift+R. The red circle in the bottom-right corner of the screen disappears.
  3. Navigate to the ~/Videos folder 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 that the built-in recorder always captures the entire screen, including all monitors in multi-monitor setups.