Search code examples
linuxbashshellwindow-managersxmonad

Xmonad, how to bind a key to running a shell script?


I'm new to xmonad. Is it possible to run a shell script (say ~/x.sh) every time you click, for example, f1? How does that look in a config file? I have googled quite a bit now without finding anything that looks like what I want.


Solution

  • Use xev to determine the keysym of your F1-key, which is on my system 0xffbe, and add

    myKeys = [ ((0, 0xffbe), spawn "/path/to/x.sh") ]
    

    to your xmonad.hs. As described in XMonad.Util.EZConfig, use

    `additionalKeys` myKeys
    

    in your main function, and recompile+restart. Probably it also works with additionalKeysP and <F1>, but i haven't tested that - the link above has all infos.