How to easily switch between multiple desktop environments?

Is there an easy way to switch between multiple desktop environments - e.g. to have Gnome/XFCE/etc all installed and select a session from the login screen? Setting the desktop manager in the configuration file seems to equate to having one. I know I’m almost certainly wrong about that but can’t find an obvious way to set it up.

It depends on the login screen but should already work! I have lightdm and can select between xmonad and xterm (a fallback I’m glad I kept!) on the top right…
I think it even caches my last selection :thinking:

Yeah, I don’t know what’s going on. I’ve managed to get Gnome and Xfce on the menu (which is what I was trying to do) but for some reason Xfce refuses to start, and if I switch out gdm for lightdm then my xserver refuses to start on boot. Peculiar.

Share your configuration! Also the logs from journalctl --boot -t xsession after you try xfce, assuming you have services.xserver.displayManager.job.logToJournal set to its default.

Ok so this happened …
I decided to forget about DEs for a while and went to play with FreeBSD in Gnome boxes. However it got stuck in a loop and wouldn’t boot so I decided to clone the VM and delete the old one. At that point my entire desktop crashed and kicked me to tty. I tried to reboot but couldn’t get past the login screen and previous generations gave me a kernel panic on boot. I managed to remove all references to virtualization software in my config file and that worked, and it ALSO fixed my earlier problem of being unable to login to XFCE :joy:
But … now I can’t start a Wayland session on Gnome unless I log in / out of an X-session first. So that’s broken.
Does anyone have a clue what might have happened?

My config is really vanilla - just some NVidia drivers that I’ve also experimented with removing, to no effect.

journalctl might, also your rather vanilla settings might have a clue :wink:

Virtualization causing problems, coupled with your apparent confusion about driver configuration, make my configuration mistake senses tingle. Kernel panics for old generations seem incredibly suspicious too.

Here are some bits from the journalctl -b

FIRST LOGIN

Sep 05 14:42:53 nixos .gnome-shell-wr[1211]: Running GNOME Shell (using mutter 44.3) as a Wayland display server
Sep 05 14:42:53 nixos .gnome-shell-wr[1211]: Device '/dev/dri/card1' prefers shadow buffer
Sep 05 14:42:53 nixos .gnome-shell-wr[1211]: Added device '/dev/dri/card1' (i915) using atomic mode setting.
Sep 05 14:42:53 nixos .gnome-shell-wr[1211]: Device '/dev/dri/card0' prefers shadow buffer
Sep 05 14:42:53 nixos .gnome-shell-wr[1211]: Added device '/dev/dri/card0' (nouveau) using non-atomic mode setting.
Sep 05 14:42:53 nixos .gnome-shell-wr[1211]: Created gbm renderer for '/dev/dri/card1'
Sep 05 14:42:53 nixos .gnome-shell-wr[1211]: Created gbm renderer for '/dev/dri/card0'
Sep 05 14:42:53 nixos .gnome-shell-wr[1211]: Boot VGA GPU /dev/dri/card1 selected as primary
Sep 05 14:42:53 nixos .gnome-shell-wr[1211]: Obtained a high priority EGL context
Sep 05 14:42:53 nixos .gnome-shell-wr[1211]: Obtained a high priority EGL context
Sep 05 14:42:54 nixos /nix/store/rljsllp6pw3xijxr2ix0li5dzyxbc3za-gdm-44.1/libexec/gdm-wayland-session[1196]: dbus-daemon[1196]: [session uid=132 pid>
Sep 05 14:42:54 nixos /nix/store/rljsllp6pw3xijxr2ix0li5dzyxbc3za-gdm-44.1/libexec/gdm-wayland-session[1196]: dbus-daemon[1196]: [session uid=132 pid>
Sep 05 14:42:54 nixos .gnome-shell-wr[1211]: Using public X11 display :1024, (using :1025 for managed services)
Sep 05 14:42:54 nixos .gnome-shell-wr[1211]: Using Wayland display name 'wayland-0'
Sep 05 14:42:54 nixos .gnome-shell-wr[1211]: Unset XDG_SESSION_ID, getCurrentSessionProxy() called outside a user session. Asking logind directly.
Sep 05 14:42:54 nixos .gnome-shell-wr[1211]: Will monitor session c1

LOGGING IN AFTER LOGGING IN/OUT OF XORG SESSION

Sep 05 15:11:11 nixos .gnome-shell-wr[5356]: GNOME Shell started at Tue Sep 05 2023 15:11:09 GMT+0100 (British Summer Time)
Sep 05 15:11:11 nixos .gnome-shell-wr[5356]: Registering session with GDM
Sep 05 15:11:11 nixos .gnome-shell-wr[4934]: Connection to xwayland lost
Sep 05 15:11:11 nixos .gnome-shell-wr[4934]: Xwayland terminated, exiting since it was mandatory
Sep 05 15:11:11 nixos .gnome-shell-wr[4934]: (../src/core/meta-context.c:501):meta_context_terminate: runtime check failed: (g_main_loop_is_running (priv->main_loop))
Sep 05 15:11:11 nixos org.gnome.Shell.desktop[4934]: GNOME Shell terminated with an error: Xwayland exited unexpectedly
Sep 05 15:11:11 nixos .gnome-shell-wr[4934]: Shutting down GNOME Shell

I tried a backup config file from a couple of days ago, when life was rosy, and the xserver wouldn’t even start. Things are odd.

Ok, I’ve narrowed it down to something in my user configs. I went back to a barebones system config with no dice. Then created a new user and their login works perfectly! Question now is, what the hell got borked?

Hum, looks like xwayland almost instantly crashes, or isn’t properly launched in the first place. I don’t think the gnome wayland session runs any xinitrc or xsession files or anything, so not the usual suspects.

Do you run any X applications on login? My gnome-foo isn’t great, so I have few pointers on gnome config that might break X.

Syncthing was the only thing running on login. I disabled it and completely reset Gnome and it was still broke. In the end I just moved across to my new user account. I’m fairly low use so it didn’t take long (although I’m now looking at home manager … ) Thanks for all the help!

Would you mind sharing your config file or a description of how you configured lightdm to allow you to select between desktop managers?

Umm checking right now with the following config (many many iterations of my configuration later) I actually don’t see the option to switch anymore! I’ve done a lot of changes to my config, as well as migrated stuff from home-manager to the system config and vice versa. So I can’t tell for sure why it was available and isn’t anymore. The config I had back then looks like that and I can’t remember tweaking lightdm otherwise:

  services.xserver = {
    enable = true;
    desktopManager = {
      xterm.enable = true;
    };
    displayManager.lightdm.enable = true;
    windowManager.xmonad = {
      enableContribAndExtras = true;
      enable = true;
    };
    libinput.touchpad.disableWhileTyping = true;
  };

My current config (lacking the option) is this for the system:

  services.xserver = {
    enable = true;
    desktopManager = {
      xterm.enable = true;
    };
    displayManager.lightdm = {
      enable = true;
      greeters.slick.enable = true;
    };
  };

And home-manager:

  xsession = {
    enable = true;
    windowManager.awesome = {
      enable = true;
    };
  };

I’m not sure if the slick greeter doesn’t have an option to change WMs or if it’s because I moved the window-manager config to home-manager and thus lightdm doesn’t “find” awesome or something like that.

I think lightdm has removed the option to switch (at least in its default configuration). I’ve started using GDM instead on occasions when I might want to switch desktop managers.