summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.xmonad/xmonad.hs29
1 files changed, 29 insertions, 0 deletions
diff --git a/.xmonad/xmonad.hs b/.xmonad/xmonad.hs
index 7594cd0..9bd67b2 100644
--- a/.xmonad/xmonad.hs
+++ b/.xmonad/xmonad.hs
@@ -66,6 +66,7 @@ data Host = Host
66 , hCoWsp :: String -> Maybe WorkspaceId 66 , hCoWsp :: String -> Maybe WorkspaceId
67 , hKeysMod :: XConfig Layout -> (KeyMap -> KeyMap) 67 , hKeysMod :: XConfig Layout -> (KeyMap -> KeyMap)
68 , hScreens :: [ScreenId] 68 , hScreens :: [ScreenId]
69 , hKbLayouts :: [(String, Maybe String)]
69 } 70 }
70 71
71defaultHost = Host { hName = "unkown" 72defaultHost = Host { hName = "unkown"
@@ -74,6 +75,10 @@ defaultHost = Host { hName = "unkown"
74 , hCoWsp = const Nothing 75 , hCoWsp = const Nothing
75 , hKeysMod = const id 76 , hKeysMod = const id
76 , hScreens = [0,1..] 77 , hScreens = [0,1..]
78 , hKbLayouts = [ ("us", Nothing)
79 , ("us", Just "dvp")
80 , ("de", Nothing)
81 ]
77 } 82 }
78 83
79hostFromName :: HostName -> Host 84hostFromName :: HostName -> Host
@@ -243,6 +248,28 @@ sshOverrides = map (\h -> mkOverride { oHost = h, oCommand = moshCmd . inTmux }
243 [ "galois", "galois.praseodym.org" 248 [ "galois", "galois.praseodym.org"
244 ] 249 ]
245 250
251cycleKbLayout :: [(String, Maybe String)] -> X ()
252cycleKbLayout [] = return ()
253cycleKbLayout layouts = liftIO $ do
254 next <- (getNext . extract) `liftM` runProcessWithInput "setxkbmap" ["-query"] ""
255 let
256 args = case next of
257 (l, Just v) -> [l, v]
258 (l, Nothing) -> [l]
259 safeSpawn "setxkbmap" args
260 where
261 extract :: String -> Maybe (String, Maybe String)
262 extract str = listToMaybe $ do
263 ["layout:", l] <- str'
264 [(l, Just v) | ["variant:", v] <- str'] ++ pure (l, Nothing)
265 where
266 str' = map words $ lines str
267 getNext :: Maybe (String, Maybe String) -> (String, Maybe String)
268 getNext = maybe (head layouts) getNext'
269 getNext' x = case elemIndex x layouts of
270 Nothing -> getNext Nothing
271 Just i -> layouts !! ((i + 1) `mod` length layouts)
272
246myKeys' conf host = Map.fromList $ 273myKeys' conf host = Map.fromList $
247 -- launch a terminal 274 -- launch a terminal
248 [ ((modm, xK_Return), spawn $ (XMonad.terminal conf) ++ " -e tmux") 275 [ ((modm, xK_Return), spawn $ (XMonad.terminal conf) ++ " -e tmux")
@@ -309,6 +336,8 @@ myKeys' conf host = Map.fromList $
309 336
310 , ((0, xF86XK_AudioRaiseVolume), safeSpawn "amixer" ["sset", "Master", "Playback", "5+"]) 337 , ((0, xF86XK_AudioRaiseVolume), safeSpawn "amixer" ["sset", "Master", "Playback", "5+"])
311 , ((0, xF86XK_AudioLowerVolume), safeSpawn "amixer" ["sset", "Master", "Playback", "5-"]) 338 , ((0, xF86XK_AudioLowerVolume), safeSpawn "amixer" ["sset", "Master", "Playback", "5-"])
339
340 , ((modm , xK_Escape), cycleKbLayout (hKbLayouts host))
312 341
313 -- Toggle the status bar gap 342 -- Toggle the status bar gap
314 -- Use this binding with avoidStruts from Hooks.ManageDocks. 343 -- Use this binding with avoidStruts from Hooks.ManageDocks.