Skip to content

XSession

Note

My modified Makefile installs DWM as a session automagically. I think. Maybe check out the Makefile. Steps below should not be necessary.

You might want to add DWM as a session to start it conveniently from a display manager.

.desktop file

For displaymanagers that parse these. As root create a file like this:

/usr/share/xsessions/dwm.desktop
[Desktop Entry]
Encoding=UTF-8
Name=dwm
Comment=Dynamic window manager
Exec=dwm
Icon=dwm
Type=XSession

with these permissions

$ ls -l /usr/share/xsessions/dwm.desktop
-rw-r--r-- 1 root root 108 Jun 27 17:24 /usr/share/xsessions/dwm.desktop

Execute a script

Optionally rather than executing dwm directly you could execute a shell script instead that writes stdout / stderr to a file for logging purposes. This also helps to autostart apps

So the .desktop file should be modified to have Exec=startdwm and you need a file with executable permissions

/usr/local/bin/startdwm
#!/bin/sh
echo "$(date): Starting dwn" >> /path/to/logs/$(date +%Y-%m-%d_%H.dwm.log)
dwm >> /path/to/logs/$(date +%Y-%m-%d_%H.dwm.log) 2>&1
$ ls -l /usr/local/bin/startdwm
-rwxr-xr-x 1 root root 204 Sep 19 14:12 /usr/local/bin/startdwm

Debian alternatives

For some displaymanagers, like XDM.

You may add your session with something like:

$ sudo update-alternatives --install /usr/bin/x-session-manager x-session-manager /usr/local/bin/startdwm 50
$ sudo update-alternatives --config x-session-manager

Credits

Thank you u/bakkeby for providing some of this information on Reddit https://www.reddit.com/r/suckless/comments/jj61py/comment/gaanvez/