Using a custom startup script for xmonad

As lightdm doesn’t call .xinitrc, I needed to find another way to start things like trayer. The easiest way is to create a file called .start-xmonad in your home directory, and point the lightdm launcher to it.

Here’s what my file looks like:

trayer --edge bottom --width 20 --height 22 --transparent true --tint 0x3c3b37 --alpha 0 &
dropbox start &
nm-applet &
xsetroot -cursor_name left_ptr  
setxkbmap -layout uk
dconf write /org/gnome/settings-daemon/plugins/xrandr/active false
feh --bg-fill ~/Documents/current-wallpaper.png
xmonad

To make the launcher use this, I needed to edit /usr/share/xsessions/xmonad.desktop. It looks like this:

[Desktop Entry]
Name=XMonad
Comment=Lightweight tiling window manager
Exec=/home/michael/.start-xmonad
Icon=xmonad.png
Type=XSession

Now, when I launch xmonad my custom setup stuff is run too

Michael is a polyglot software engineer, committed to reducing complexity in systems and making them more predictable. Working with a variety of languages and tools, he shares his technical expertise to audiences all around the world at user groups and conferences. You can follow @mheap on Twitter

Thoughts on this post

zhefa 2014-10-13

I thought you ditched xmonad and used i3 instead? Are you going back to xmonad?

michael 2014-10-13

I did, then after a few months I switched back. I became more comfortable with tiling WM’s and was missing xmonad’s layout support

Gauthier 2017-08-14

Rather than modifying system files, you could achieve the same with only user files.
/usr/share/xsessions/xmonad.desktop calls to /usr/bin/xmonad-session, which in turn sources .xmonad/xmonad-session-rc.
Create this last file in your $HOME and you’re good to go, even if you don’t have superuser permissions.

Leave a comment?

Leave a Reply