0

I'm trying out Xmonad and am building a config file. However I have an issue with the keybindings. Some of my keybindings are working and some aren't. It makes no sense to me why. It compiles just fine, no errors. And to me either all should work or none. Why just some?

For instance I can launch a terminal, lock my screen, launch the file manager but i can't launch firefox or vscode. And the same in the next section. I can launch rofi launcher, rofi window finder but dmenu and rofi exit menu aren't working with this in my config:

terminalCmd         = "alacritty"
browserCmd          = "firefox"
editorCmd           = "code"
fileManagerCmd      = "nautilus --new-window"
dmenuCmd            = "dmenu_run"
rofiCmd             = "rofi -show drun -theme clean"
rofiWinCmd          = "rofi -show window -theme clean_window"
rofiExitCmd         = "~/.config/rofi/launch.sh powermenu"
screenLockCmd       = "slock"
myFocusFollowsMouse = True

myKeybindings conf@XConfig {modMask = modMask} = M.fromList $
    --Launch programs
    [ ((modMask, xK_Return), spawn terminalCmd)              --Launch terminal
    , ((modMask, xK_w), spawn browserCmd)                    --Launch browser
    , ((modMask, xK_e), spawn editorCmd)                     --Launch editor
    , ((modMask, xK_a), spawn fileManagerCmd)                --Launch file manager
    , ((modMask, xK_l), spawn screenLockCmd)                 --Lock the screen

    --Launchers and menus
    , ((modMask, xK_r), spawn dmenuCmd)                      --Launch dmenu launcher
    , ((modMask, xK_p), spawn rofiCmd)                       --Launch rofi launcher
    , ((modMask .|. shiftMask, xK_p), spawn rofiWinCmd)      --Launch rofi window finder
    , ((modMask .|. shiftMask, xK_e), spawn rofiExitCmd)     --Launch rofi exit menu

main = xmonad $ def
    { modMask             = mod4Mask
    , focusFollowsMouse   = myFocusFollowsMouse
    , borderWidth         = 1
    , terminal            = terminalCmd
    , normalBorderColor   = "#cccccc"
    , focusedBorderColor  = "#cd8b00"
    , workspaces          = myWorkspaces 
    , keys                = myKeybindings
    , startupHook         = myStartupHook }
Silvio
  • 151
  • 9

1 Answers1

1

Here's how I would debug the problem.

  1. Try typing the raw command in a terminal. If that doesn't work, them you know the problem isn't with your XMonad configuration or XMonad, it's with the command itself.

  2. If the command works in the terminal, try binding it to a different key in your XMonad. If that works, then the issue is with the key bindings. Launch xev, press the key you want to use, and double-check the name of the event that is triggered.

  3. Take one of the commands that are currently working when you use XMonad to launch them, and try also binding it to one of the keys that you're having a problem with.

  • If it works, then there's something wrong with your original command. If step 1 worked, then the problem may have something to do with launching the command directly in XWindows instead of a terminal.

  • If it doesn't work, that's more confirmation that you're not using the right key binding.

Also, to rule out any difference between the value of the PATH environment variable that XMonad sees and the one that the terminal sees, try supplying the full path to the command in your configuration.

mhwombat
  • 8,026
  • 28
  • 53