5

Im only just beginning haskell and xmonad. I was wondering how one would configure it so that if no windows were open, any key input would launch dmenu. So say if i had a blank screen and started to type "firefox", dmenu would launch with my "firefox" for example within it.

Hardly important but it would be nice if I could get some pointers in the right direction :)

mlihp
  • 485
  • 4
  • 12
  • @closevoter xmonad is (written and) configured in genuine haskell. You literally program the windowing system. You can't configure xmonad without writing haskell. It's programming. – AndrewC Jul 03 '13 at 12:24

1 Answers1

2

It's an interesting idea! For the moment, let's assume that you want to map just the 'f' key. The approach that comes to my mind is to map the key to a function that checks if there are any windows open. If there are no windows open, it launches dmenu, pre-populating it with the character you just typed (i.e., the 'f'). If there are other windows open, it does whatever you normally want that key to do.

 main = xmonad $ blah blah blah
             `additionalKeys`
                [
                  ((0, xK_f), multiMapKey f someAction)
                  -- other mappings
                ]


multiMapKey :: Char -> X () -> X ()
multiMapKey c someAction =
  if ?a window is open?
    then launch dmenu with c already entered
    else someAction

Notes:

  1. I don't know how to find out if a window is already open, but I suspect you'll find a function for this in the xmonad or xmonad-contrib package.
  2. I don't know how to launch dmenu with a character already typed. Maybe there's something in XMonad.Util.Dmenu that will help.
  3. I think you'll have to have a separate entry in additionalKeys for each key you want to map. Maybe just mapping the 26 alphabetic keys will be sufficient.

For learning more about the Xmonad innards, I recommend jekor's videos: part 1 part 2

mhwombat
  • 8,026
  • 28
  • 53