How to set a default desktop environment at system start?

24

13

I'm a Linux and KDE user, and recently I started to use also Enlightenment as a substitute Desktop environment when I need a lighter resource consumption.

I use KDM as a display manager, and I need to find a way to correctly set the default desktop environment to my preferences.

I wish to be able to set KDE as the default choice because I use it on a daily basis, and manually pick a different one just when I need it.

Currently it is set to boot the last used DE, and I can't find how to change this behaviour. The KDM control module in KDE System Settings does not seem to offer me this option.

Any clues on how can I do it?

Sekhemty

Posted 2013-12-09T15:54:44.503

Reputation: 6 654

Can't you chose a DE before logging in? There should be a session menu or similar that allows you to chose the session you want to run. – terdon – 2013-12-09T15:59:48.673

Yes, but I've set it up to automatically login with my account, without asking for a specific user (I'm the only user of the computer). – Sekhemty – 2013-12-09T16:43:10.157

I don't think there is a way to both log in automatically and be able to chose a session. – terdon – 2013-12-09T16:47:55.453

1I understand. But if it automatically logins in the last used environment, there should be some place where the system is told to behave like this, where it must check what was the last used and then to select it. – Sekhemty – 2013-12-09T16:52:53.283

And, in your experience, is this behaviour specifically related to my display manager (KDM) or it's a setting that has nothing to do with it? Should I expect to have the same situation also with, in example, LightDM? – Sekhemty – 2013-12-09T16:55:23.233

Answers

24

You should be able to set this up by editing your $HOME/.dmrc file. The sessions available to your display manager (whichever one you use) are .desktop files normally located in /usr/share/xsessions. In my case, this directory contains:

$ ls /usr/share/xsessions
cinnamon2d.desktop  gnome-fallback.desktop  openbox-gnome.desktop  xfce.desktop
cinnamon.desktop    mate.desktop            openbox-kde.desktop
gnome.desktop       openbox.desktop         ssh.desktop

Any of those files is a possible session that my display manager can choose. Which one is controlled by the $HOME/.dmrc file. So, to make KDE the default, you would have to edit that file and make it look like this:

[Desktop]
Session=kde-plasma

That assumes that you have a kde.desktop file in the xsessions directory, I don't use KDE so I can't check but it works for me using cinnamon or xfce. Once you have made that change, you should be logged in to KDE by default every time.

terdon

Posted 2013-12-09T15:54:44.503

Reputation: 45 216

2does not work for me.I'm using CentOS 7. having gnome-classic.desktop, gnome.desktop, mate.desktop. set Session=mate but does not work – vee – 2015-12-11T14:30:58.433

@vee maybe things have changed since then, it's been 2 years after all. Try asking a new question and linking to this answer, explaining that it didn't work. Make sure you tell us exactly what files you edited and also what login manager you are using. – terdon – 2015-12-11T14:34:46.497

It showed me lightdm-session. I replaced with gnome but not working. – Pandya – 2019-03-20T03:46:31.020

@Pandya yes, see the answer by yrHeTaTeJlb, it looks like it works differently these days.

– terdon – 2019-03-20T09:23:33.477

1Thank you. You like many different environments yourself, don't you? :) Anyway, in my system, in the /usr/share/xsessions, the KDE entry is named kde-plasma.desktop; I suppose that this is because KDE also provides other environments (i.e. the Active for mobile devices) besides Plasma, the standard for desktops. Since I haven't modified anything here, I'm quite sure that it's the standard name; you might want to upgrade your answer to reflect this. I will try out this procedure and see if it works. – Sekhemty – 2013-12-09T17:34:36.960

@Sekhemty thanks, answer edited. It should work, I installed kdm just for you :) and tested by switching between cinnamon and xfce, it logged me into the default each time. – terdon – 2013-12-09T17:45:31.573

Already done, at least for me it is shown as accepted. Maybe the server has not yet updated the status? – Sekhemty – 2013-12-09T20:33:16.640

@Sekhemty damn, sorry, just noticed your rep level and realized you already know how the site works :). Yup, all accepted here too, thanks! – terdon – 2013-12-09T20:36:36.320

There is no problem! – Sekhemty – 2013-12-09T20:46:55.120

8

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

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=mate

Source

yrHeTaTeJlb

Posted 2013-12-09T15:54:44.503

Reputation: 181

2

For RHEL/CentOS 7 you can set the file /etc/sysconfig/desktop to contain DESKTOP=KDE which will default it to KDE.

This also works for VNC.

Everlight

Posted 2013-12-09T15:54:44.503

Reputation: 163

1

Works for Centos 7/RHEL If $HOME/.dmrc doesn't exists:

  1. From dir /usr/share/xsessions move all *.desktop file to another directory(unnecessary_env, for example) and leave only one you need(in my case - xfce.desktop):

    $ ls /usr/share/xsessions xfce.desktop unnecessary_env/

  2. After logout/reboot XFCE will be loaded by default

Note! You won't be able to choose between GUI

c ccx

Posted 2013-12-09T15:54:44.503

Reputation: 21

My default desktop environment is not under /usr/share/xsessions. I'm on kali Linux and see System X11 Default and gnome-classic as options. But in xsessions, only gnome-classic.desktop exists. Any tips..? – borizzzzz – 2019-06-15T15:24:43.657

Whatever I tried, Kali would keep using GNOME as default, moving the unnecessary *.desktop files out of /usr/share/xsessions was the only reliable method to force Kali to use Cinnamon by default. Thanks! – Tox – 2020-01-26T12:54:06.270