guest@dotshare [~/groups/misc/misc] $ ls My-xinitrc-menu-system/ | cat

My xinitrc menu system (raw, dl)

rabbit386 Nov 16, 2021 (misc/misc)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
if [[ "$LOGNAME" == "rabbit" ]]
then
        if [[ "`tty`" == "/dev/tty1" ]]
        then
                echo ls -1 /home/rabbit/.sessions | /bin/sh | termenu | read sessionpath
                if [[ "$sessionpath" == "5 Console" ]]
                then
                        clear
                else
                        startx /home/rabbit/.sessions/"$sessionpath"/init
                        logout
                fi
        fi
fi

CLICK TO VIEW

x

Notes

I wrote this while dead drunk and revised it later; this is a pure xorg-xinit-based display management system that displays a menu (using termenu) and launches a WM or falls through to the console

If you dislike the footprint and lack of hackability of a display manager/session manager, this is an easy solution that allows you to run your favorite window manager with a single keystroke after logging in, but also gives you the option to run something else instead. As each entry in the menu is a folder containing a xinitrc script, setting up a window manager is as easy as creating a folder and writing or dropping in a script.

To install:

  • Install termenu (pip install termenu)

  • Create the directory ~/.sessions

  • For each window manager you have installed, create a subdirectory in .sessions of the format “1 Calm Window Manager”, “2 dwm”, “3 some other Window Manager” and so on. Strictly speaking they don’t have to be numbered but I like being able to control the sorting order

  • Create an empty folder called something like “[N] Console” where N is wherever you want a console session to fall in the list. Or don’t, if you don’t need the option to fall through to a console. A nice alternative is just invoking your favorite terminal without a window manager, while specifying geometry to fill the screen.

  • Make a xinitrc file called “init” for each wm and place it in the corresponding folder

  • Edit the following file replacing “rabbit” with your username and “5 Console” with whatever you named the empty folder

  • With root privileges place it in /etc/profile.d, where it will be the last profile script run on login.

  • I suggest having a .commonrc script that is sourced in each init file which does the configuration common to each WM

May need to edit /dev/tty1 to /dev/tty7 or something on a lot of mainline distros that use systemd-logind; I use Arch, which has logind configured to put the first session on /dev/tty1