Shell – handling multiple window managers, multiple .xsessionrc files

configurationgnome-shellwindow-managerxmonad

I have just installed xmonad on my laptop with Debian jessie, and like it so far… I have previously used the default gnome-shell desktop (/window?) -manager, and still want to keep it 100% intact while I'm learning how to use xmonad.

Many xmonad tutorials talk about modifying the .xsessionrc file to add for example wallpapers, and so on http://beginners-guide-to-xmonad.readthedocs.io/wallpaper.html. However, I'm guessing that messing with the .xsessionrc file will also affect gnome-shell…

Is it somehow possible to have multiple .xsessionrc files, such that I can have one for xmonad and one for gnome-shell?.. or is there perhaps a better solution to this problem?

I wish to keep the gnome-shell session as it is, and I also wish to keep the default display manager for login.

Best Answer

.xsessionrc is executed for all session types. The session type is available in the variable STARTUP (for most session types), so you can put conditional statements in your .xsessionrc:

case "$STARTUP" in
  xmonad-session) …;;
  gnome-session) …;;
esac

The X session startup scripts are documented in Xsession(5). You may need to read the code in /etc/X11/Xsession and /etc/X11/Xsession.d/* for more details.

Note that .xsessionrc is specific to Debian and derivatives. See Difference between .xinitrc, .xsession and .xsessionrc for a discussion of standard X session files. The standard file .xsession only applies if you select “custom session” in the display manager when logging in, and .xinitrc only applies if you run startx (or xinit) after logging in in text mode.

Related Question