www-gem words

Specific WM for a given TTY

Published on

Today’s tweak is about auto launching a given windows manager (WM) based on the TTY you’re login from.

You may have good reasons to use different windows managers on your machine or you just like to switch from one to the other depending on your mood. Whatever your reason is, you may sometimes run both at the same time and in such situations it can be boring to have to tell your machine which WM you want to use, and it can even be more frustrating when you forget to do it and launch the same WM twice in different sessions. To help with that, you can simply link a WM to a TTY. This will allow you to have a defined WM automatically launched when you login from a specific TTY.

Let’s see how that work in the real world. Try to add this code to your .zprofile:

if [[ -z $DISPLAY && $XDG_VTNR -eq 4 ]]; then
	exec dwl -s 'sh ~/.dwl_startup.sh'
else
	exec startx
fi

Also, add this add the end of your .xinitrc:

    if [ "${XDG_VTNR}" -eq 1 ]; then
        exec bspwm
    elif [ "${XDG_VTNR}" -eq 2 ]; then
        while :; do
            ssh-agent dwm
        done
        exec dwm
    elif [ "${XDG_VTNR}" -eq 3 ]; then
        exec i3
    fi
fi

In this specific example (to be adjusted to your needs):

  1. .zprofile will launch the dwl wayland WM if you login from a TTY less than 4 and launch startx otherwise
  2. if startx is called, then .xinitrc will be read and:

Thanks for your read. Hope it's been useful to you.


Interact with this post using Mastodon or

Comment on wwwgem's post

Copy and paste this URL into the search field of your favourite Fediverse app or the web interface of your Mastodon server.

✄ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈

More food for thoughts? Check other posts about: #System