xinit

about | blog | config | notes | github

1. X Window System Initializer

The xinit program allows a user to manually start the Xorg X11 Window System without the need of a login manager. However, this also means that we have to manually manage our environments ourselves. We won't directly use xinit, but rather startx which is a nicer frontend for xinit that is bundled alongside it.

2. Configuration

2.1. Package Install

Install the xinit package, but not before setting up Xorg X11 Window System.

(require 'init-xorg)
(zamlz/system-packages-ensure "xorg-xinit" "startx")
(provide 'init-xinit)

2.2. Xinitrc

. $HOME/org/config/lib/shell/logger
LOGGER=$(get_logger xinitrc)

Some linux distros have predefined scripts in these locations that need to be sourced in order for proper Xorg operation. Source the global defaults and then the local files if any exist.

$LOGGER "Sourcing xinitrc.d files if they exist"
if [ -d /etc/X11/xinit/xinitrc.d ] ; then
    for f in /etc/X11/xinit/xinitrc.d/*.sh ; do
        [ -x "$f" ] && . "$f"
    done
    unset f
fi

Make sure to source this stuff to before reloading it for the first time.

if [ -d $HOME/.config/xinitrc.d ] ; then
    find "$HOME/.config/xinitrc.d" -name "*.sh" | while read -r f; do
        [ -x "$f" ] && . "$f"
    done
    unset f
fi

This part of the script decides which window manager to start. This is ultimately passed as an argument to starx. It is configured from $1 which must be passed to it. Currently we have options to trigger the Herbstluftwm Tiling Window Manager and GNU/Emacs.

session=${1:-herbstluftwm}
$LOGGER "Starting session: $session"

case $session in
    herbstluftwm)   herbstluftwm;;
    exwm)           emacs -mm --debug-init;;
    *)             exec $1;;
esac

2.3. User-Level Configurations

We create a seperate shell script for invoking the user-level scripts. The reason is seperate is so that other window managers can run them as well when refreshing their configuraiton. NOTE: This also means that any window manager that is started, should make a call to this script (refresh-xinitrc.sh).

You should also add any system specific configurations here as well (like monitor setups, etc. )

if [ -d $HOME/.config/xinitrc.d ] ; then
    find "$HOME/.config/xinitrc.d" -name "*.sh" | while read -r f; do
        [ -x "$f" ] && . "$f"
    done
    unset f
fi

Created: 2021-11-13

Emacs 26.1 (Org mode 9.5)