summaryrefslogtreecommitdiffstats
path: root/pkgs/haskell/xmonad-tv/src/Shortcuts.hs
blob: 3ac7070b789cc411a67fd68eee0e774ae0a0b587 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module Shortcuts
    ( Config
    , new
    )
  where

import Data.Map (Map)
import System.Posix.Process (executeFile)
import XMonad (Layout, KeyMask, KeySym, X, XConfig, xfork)
import XMonad.Util.EZConfig (mkKeymap)
import qualified Data.Map.Strict as Map


type Config = Map String String


new :: Config -> XConfig Layout -> Map (KeyMask, KeySym) (X ())
new config xconfig =
    mkKeymap xconfig $
      map (\(key, path) -> (key, forkFile path [] Nothing)) $
      Map.toList config


forkFile :: FilePath -> [String] -> Maybe [(String, String)] -> X ()
forkFile path args env =
    xfork (executeFile path True args env) >> return ()