xmonad doesn't start with "startx" command

wolverine96

Reputable
Mar 26, 2014
1,237
0
5,660
I have recently installed Arch Linux on my computer. Xorg has been successfully installed, and when I run "startx" it opens the default Xorg screen with three xterm terminals and an xclock.

The problem is that I have installed xmonad for the window manager, and it won't start when Xorg does. I have edited the ~/.xinitrc file and added the line "exec xmonad" to the bottom (also tried just "xmonad"), but when I run "startx" it still uses Xorg's WM. Following this suggestion in the Arch Wiki, I ran "startx /usr/bin/xmonad" and that actually works. Therefore, I know the problem is not with xmonad.

Can anyone help me get Xmonad to start when I just run "startx"? Any help will be greatly appreciated!
 
Solution
I assume that first line is a typo. It should read:

#!/bin/sh

Also, are the permissions on .xinitrc correct? (It should be executable.)
Yes, I have that folder. And my xmonad.hs looks like this:


Code:
import XMonad
main = do
    xmonad $ defaultConfig

What annoys me is that everything works fine when I run "startx path/to/xmonad". Does Xorg always use it's own window manager by default? I'm thinking maybe there is a line I should comment out? I tried commenting out everything in the ~/.xinitrc file except "exec xmonad" but that did nothing.
 
What happens when you do

xmonad --recompile

Maybe try to reinstall xmonad
#pacman -S xmonad
#pacman -S xmonad-contrib

From what I gather from using arch, xmonad is very finicky. Read through archwiki on xinitrc and xmonad again. Maybe consult gentoo wiki as well.

You can always make an alias 'startx' to 'startx /usr/bin/xmonad' if you can get it working.
 

I tried that already. Nothing happened, but thanks. I think that would only apply to the xmonad.hs file.


Thanks for the suggestion. I had wondered about that too, but after doing it just now, I still have the same problem.


Here's the whole file:

Code:
#!/bin/sh
# ~/.xinitrc
# Executed by startx (run your window manager from herer)

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

# Start xmonad window manager
exec xmonad
(I had to type this out by hand :))


Will do! I'll uninstall xmonad and then start all over using the ArchWiki. (But not right now, it's midnight, LOL!)

By the way, I should have mentioned this before, but I have been following this article. It did help me discover that "Oh, I need to install Xorg and my graphics diver first," but maybe the information about xmonad is outdated (it's from 2011).
 

Yes, that ~ was a typo.


Thank you! The permissions where not set correctly. I fixed it, and now it works as it should!

For anyone else reading this with the same problem, run this command:
Code:
chmod +x .xinitrc
Also, the correct location for ~/.xinitrc is in /root for the root user and /home/<username>/ for other users.