How to configure default desktop session in RHEL7 ?

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux 7
  • KDE
  • GNOME

Issue

  • How to configure KDE-Plasma the system wide default session in RHEL7.0 and RHEL7.1?
  • How to configure user default session in RHEL7 ?
  • How to configure GNOME3 Classic, GNOME or KDE-Plasma as user's default session ?
  • How to set default desktop environment in RHEL7.0 and RHEL7.1 ?

Resolution

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

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

To set the system wide default session for all users :

Setting "KDE-Plasma" as default desktop for all users:

  • Create /etc/X11/sessions directory and put copies of the gnome-session-xsession and gnome-classic-session session files in it. Make sure you give it a filename that sorts higher than the kde files.
# mkdir /etc/X11/sessions
# cp /usr/share/xsessions/gnome-classic.desktop /etc/X11/sessions/3-gnome-classic.desktop
# cp /usr/share/xsessions/gnome.desktop /etc/X11/sessions/4-gnome.desktop

# ll /usr/share/xsessions/| grep kde
-rw-r--r--. 1 root root 4791 Apr 29 14:57 1-kde-plasma-standard.desktop
-rw-r--r--. 1 root root 7208 Apr 29 14:57 2-kde-plasma-safe.desktop

Note: In above example the gnome session files has been prefix with number higher than kde files.

  • Remove gnome-session-xsession and gnome-classic-session packages from system:
# rpm -e gnome-session-xsession gnome-classic-session
  • Restart gdm.service :
# systemctl restart gdm.service

Note: In order to set "gnome" as a default desktop session for all users, there is no need to remove gnome-session-xsession and gnome-classic-session packages. Just set lower prefix for gnome.desktop in /usr/share/xsessions/ directory.

To specify a default session for a user, there are two methods:

Method-1

  • First logout all users from graphical session.
  • Login into the system via ssh and confirm that gnome-session-xsession package is installed on the system.
  • Navigate to the /usr/share/xsessions directory which contains .desktop files for each of the available session and select the name of the file to set it default.
$ ll /usr/share/xsessions
-rw-r--r--. 1 root root 4791 Apr 29 14:57 1-kde-plasma-standard.desktop
-rw-r--r--. 1 root root 7208 Apr 29 14:57 2-kde-plasma-safe.desktop
-rw-r--r--. 1 root root 3376 May 28 19:35 gnome-classic.desktop
-rw-r--r--. 1 root root 6960 Mar 10 23:27 gnome-custom-session.desktop
-rw-r--r--. 1 root root 7090 Mar 10 23:27 gnome.desktop
  • Kill accounts-daemon and modify the user's default session in /var/lib/AccountsService/users/username file:
#  pkill -f accounts-daemon 
# cat /var/lib/AccountsService/users/username
[User]
Language=
XSession=gnome-classic

In this example, GNOME Classic has been set as user's default session, using the /usr/share/xsessions/gnome-classic.desktop file.

Method-2

  • Logout all users from graphical session and execute below command as root user:
# gdbus call --system --dest org.freedesktop.Accounts --object-path /org/freedesktop/Accounts/User<UID> --method org.freedesktop.Accounts.User.SetXSession "1-kde-plasma-standard"

In above example kde-plasma has been set as the default session.

  • Login into the system to verify the default session.

Additional notes related to specifying default session for individual user:

  • Do not select a different session from the login screen otherwise the above settings will not work.
  • There is no need to kill accounts-daemon before execution of command mentioned in second method.
  • None of the above method can be used to set default session for root user. The above methods are applicable to non-root users only.
SBR
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.