Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XMonad won't spawn anything with mod4Mask

I have seen a few somewhat similar problems on the Arch forums, but I have not been able to find a solution for this.

So I am running XMonad 0.1 in XFCE4 on Fedora 17 x64, and I have xmonad-contrib installed as well. Here is my xmonad.hs file:

import System.Posix.Env (getEnv)
import Data.Maybe (maybe)
import Control.Monad
import XMonad.Hooks.SetWMName
import qualified XMonad.StackSet as W
import XMonad.Util.EZConfig

import XMonad
import XMonad.Config.Desktop
import XMonad.Config.Gnome
import XMonad.Config.Kde
import XMonad.Config.Xfce

main = do
     session <- getEnv "DESKTOP_SESSION"
     xmonad  $ xfceConfig     --(maybe desktopConfig desktop session)        
        {
        modMask = mod4Mask
        , terminal = "gnome-terminal"
        , logHook = takeTopFocus >> setWMName "LG3D"
        }
        `additionalKeys` [ ((mod4Mask, xK_p), spawn "dmenu_run")
                           ,((mod4Mask, xK_v), spawn "gvim")
            ]


-----------------------------------------
------------Custom Keys------------------
-----------------------------------------


-----------------------------------------
------------Other horrible stuff---------
-----------------------------------------

desktop "gnome" = gnomeConfig
desktop "kde" = kde4Config
desktop "xfce" = xfceConfig
desktop "xmonad-gnome" = gnomeConfig
desktop _ = desktopConfig

atom_WM_TAKE_FOCUS ::
  X Atom
atom_WM_TAKE_FOCUS =
  getAtom "WM_TAKE_FOCUS"

takeFocusX ::
  Window
  -> X ()
takeFocusX w =
  withWindowSet . const $ do
    dpy       <- asks display
    wmtakef   <- atom_WM_TAKE_FOCUS
    wmprot    <- atom_WM_PROTOCOLS
    protocols <- io $ getWMProtocols dpy w
    when (wmtakef `elem` protocols) $
      io . allocaXEvent $ \ev -> do
          setEventType ev clientMessage
          setClientMessageEvent ev w wmprot 32 wmtakef currentTime
          sendEvent dpy w False noEventMask ev

takeTopFocus ::
  X ()
takeTopFocus =
  withWindowSet $ maybe (setFocusX =<< asks theRoot) takeFocusX . W.peek

You will notice in the additionalKeys part, I have 2 bindings. Both are using mod4Mask, which is also my default mod key. The second binding, for gvim, works perfectly. The problem is that the first binding, for dmenu, simply does nothing. What's strange is that if I change mod4Mask (for dmenu) to mod1Mask then it works. Also, dmenu works fine if I run it from a terminal.

EDIT: mod4Mask and P doesn't seem to spawn / do anything.

Any ideas? This config seems fine to me, I have no idea why it won't work.

like image 652
geniass Avatar asked Oct 23 '22 07:10

geniass


2 Answers

I don't know what's wrong, but I have a few suggestions for debugging it.

  1. I've had situations where I thought I was running my current custom xmonad.hs, but I was really running a previous version or the default. Rule this out by making some other change to your xmonad.hs, and verifying that it works.

  2. Try mapping mod4Mask p to something else, and see if that works.

  3. Using xev, press mod4Mask + p, and verify that it indeed generates the events you're expecting. Compare with mod4Mask + v, and see if there's any difference apart from the change from p to v.

  4. Make sure you don't have NumLock or Fn or something like that active! (NumLock would change your p to a number, I think.)

What kind of keyboard are you using? US? UK? Something else?

like image 154
mhwombat Avatar answered Oct 27 '22 00:10

mhwombat


XFCE binds Mod4-p to something in this file

~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml

By searching for "Super" in that file I find two lines with < Super>-p. One seems to be "empty" and the other executes "xfce4-display-settings --minimal" for setting up an external display output.

I changed both occurrences in that file to use o instead of p and then logged out of XFCE and back in. Now Mod4-p works in XMonad!

like image 38
Jonatan Kallus Avatar answered Oct 26 '22 23:10

Jonatan Kallus