summaryrefslogtreecommitdiff
path: root/.xmonad/xmonad.hs
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2015-11-03 13:26:44 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2015-11-03 13:26:44 +0100
commit269f143489fa77200799ed0e1199762733d86252 (patch)
treee25add6ea7bd0a50dc8370653b10a785c5b9e6d0 /.xmonad/xmonad.hs
parent6ef619c9e351d7a3a9d066c67ede58e5f4c31c18 (diff)
parent48cd5862c2982ec6f48d086e8683d486588e3f4f (diff)
downloaddotfiles-269f143489fa77200799ed0e1199762733d86252.tar
dotfiles-269f143489fa77200799ed0e1199762733d86252.tar.gz
dotfiles-269f143489fa77200799ed0e1199762733d86252.tar.bz2
dotfiles-269f143489fa77200799ed0e1199762733d86252.tar.xz
dotfiles-269f143489fa77200799ed0e1199762733d86252.zip
Merge branch 'master' of git.yggdrasil.li:dotfiles
Diffstat (limited to '.xmonad/xmonad.hs')
-rw-r--r--.xmonad/xmonad.hs107
1 files changed, 74 insertions, 33 deletions
diff --git a/.xmonad/xmonad.hs b/.xmonad/xmonad.hs
index 4e04fee..353041d 100644
--- a/.xmonad/xmonad.hs
+++ b/.xmonad/xmonad.hs
@@ -14,7 +14,7 @@ import Control.Monad.State (get)
14import XMonad.Layout.Spiral 14import XMonad.Layout.Spiral
15import Data.Ratio 15import Data.Ratio
16import Data.List 16import Data.List
17import Data.Maybe (fromMaybe, listToMaybe) 17import Data.Maybe (fromMaybe, listToMaybe, catMaybes)
18import XMonad.Layout.Tabbed 18import XMonad.Layout.Tabbed
19import XMonad.Prompt 19import XMonad.Prompt
20import XMonad.Util.Scratchpad 20import XMonad.Util.Scratchpad
@@ -25,6 +25,7 @@ import XMonad.Layout.PerWorkspace
25import XMonad.Layout.SimplestFloat 25import XMonad.Layout.SimplestFloat
26import XMonad.Layout.Renamed 26import XMonad.Layout.Renamed
27import XMonad.Layout.Reflect 27import XMonad.Layout.Reflect
28import XMonad.Layout.OnHost
28import System.Process 29import System.Process
29import System.Directory (removeFile) 30import System.Directory (removeFile)
30import System.Posix.Files 31import System.Posix.Files
@@ -39,6 +40,9 @@ import Control.Monad (when)
39import Graphics.X11.ExtraTypes.XF86 40import Graphics.X11.ExtraTypes.XF86
40import XMonad.Util.Cursor 41import XMonad.Util.Cursor
41import XMonad.Actions.Warp 42import XMonad.Actions.Warp
43import XMonad.Util.SpawnOnce
44import System.Directory
45import System.FilePath
42 46
43import XMonad.Layout.IM 47import XMonad.Layout.IM
44 48
@@ -47,44 +51,78 @@ import XMonad.Prompt.MySsh
47 51
48import Network.HostName 52import Network.HostName
49 53
54import Control.Applicative ((<$>))
55
50type KeyMap = Map (ButtonMask, KeySym) (X ()) 56type KeyMap = Map (ButtonMask, KeySym) (X ())
51 57
52data Host l1 l2 = Host 58data Host = Host
53 { hName :: HostName 59 { hName :: HostName
54 , hManageHook :: ManageHook 60 , hManageHook :: ManageHook
55 , hWsp :: Integer -> WorkspaceId 61 , hWsp :: Integer -> WorkspaceId
56 , hLayoutMod :: l1 -> l2 62 , hCoWsp :: String -> Maybe WorkspaceId
57 , hKeysMod :: XConfig Layout -> (KeyMap -> KeyMap) 63 , hKeysMod :: XConfig Layout -> (KeyMap -> KeyMap)
64 , hScreens :: [ScreenId]
58 } 65 }
59 66
60defaultHost = Host { hName = "unkown" 67defaultHost = Host { hName = "unkown"
61 , hManageHook = composeOne [manageScratchTerm] 68 , hManageHook = composeOne [manageScratchTerm]
62 , hWsp = show 69 , hWsp = show
63 , hLayoutMod = id 70 , hCoWsp = const Nothing
64 , hKeysMod = const id 71 , hKeysMod = const id
72 , hScreens = [0,1..]
65 } 73 }
66 74
67--hostFromName :: (LayoutClass l1 a, LayoutClass l2 a) => HostName -> Host (l1 a) (l2 a) 75hostFromName :: HostName -> Host
68hostFromName h@("vali") = defaultHost { hName = h 76hostFromName h@("vali") = defaultHost { hName = h
69 , hManageHook = hManageHook defaultHost 77 , hManageHook = composeOne $ catMaybes [ Just manageScratchTerm
70 , hWsp = \i -> case Map.lookup i workspaceNames of 78 , assign "web" $ className =? ".dwb-wrapped"
71 Just str -> show i ++ " " ++ str 79 , assign "web" $ className =? "Chromium"
72 Nothing -> show i 80 , assign "work" $ className =? "Emacs"
73 , hLayoutMod = id 81 ]
74 , hKeysMod = \conf -> Map.union $ Map.fromList $ join $ map (spawnBindings conf) [ (xK_d, ["dwb", "dwb $(xclip -o)"]) 82 , hWsp = hWsp
75 ] 83 , hCoWsp = hCoWsp
84 , hKeysMod = \conf -> Map.union $ Map.fromList $ join $ map (spawnBindings conf) [ (xK_d, ["chromium", "chromium $(xclip -o)"])
85 , (xK_e, ["emacsclient -c"])
86 ]
87 , hScreens = [1, 0] ++ [2,3..]
76 } 88 }
77 where 89 where
78 workspaceNames = Map.fromList [ (1, "web") 90 workspaceNames = Map.fromList [ (2, "web")
91 , (3, "work")
79 ] 92 ]
93 hWsp = wspFromMap workspaceNames
94 hCoWsp = coWspFromMap workspaceNames
95 assign wsp test = (\wsp -> test -?> doShift wsp) <$> hCoWsp wsp
80hostFromName _ = defaultHost 96hostFromName _ = defaultHost
81 97
98wspFromMap workspaceNames = \i -> case Map.lookup i workspaceNames of
99 Just str -> show i ++ " " ++ str
100 Nothing -> show i
101
102coWspFromMap workspaceNames = \str -> case filter ((== str) . snd) $ Map.toList workspaceNames of
103 [] -> Nothing
104 [(i, _)] -> Just $ wspFromMap workspaceNames i
105 _ -> Nothing
106
82spawnModifiers = [0, controlMask, shiftMask .|. controlMask] 107spawnModifiers = [0, controlMask, shiftMask .|. controlMask]
83spawnBindings conf (k, cmds) = zipWith (\m cmd -> ((modm .|. mod1Mask .|. m, k), spawn cmd)) spawnModifiers cmds 108spawnBindings conf (k, cmds) = zipWith (\m cmd -> ((modm .|. mod1Mask .|. m, k), spawn cmd)) spawnModifiers cmds
84 where 109 where
85 modm = XMonad.modMask conf 110 modm = XMonad.modMask conf
86 111
87manageScratchTerm = resource =? "scratchpad" -?> doRectFloat $ RationalRect (1 % 16) (1 % 16) (7 % 8) (7 % 8) 112manageScratchTerm = (resource =? "scratchpad" <||> resource =? "keysetup") -?> doRectFloat $ RationalRect (1 % 16) (1 % 16) (7 % 8) (7 % 8)
113
114tabbedLayout t = renamed [Replace "Tabbed"] $ reflectHoriz $ t CustomShrink $ tabbedTheme
115tabbedTheme = defaultTheme { activeColor = "black"
116 , inactiveColor = "black"
117 , urgentColor = "black"
118 , activeBorderColor = "white"
119 , inactiveBorderColor = "#202020"
120 , urgentBorderColor = "#bb0000"
121 , activeTextColor = "white"
122 , inactiveTextColor = "white"
123 , urgentTextColor = "white"
124 , decoHeight = 16
125 }
88 126
89main = do 127main = do
90 xmobarProc <- spawnPipe "xmobar" 128 xmobarProc <- spawnPipe "xmobar"
@@ -95,26 +133,26 @@ main = do
95 , layoutHook = smartBorders $ avoidStruts layout' 133 , layoutHook = smartBorders $ avoidStruts layout'
96 , logHook = dynamicLogWithPP xmobarPP' 134 , logHook = dynamicLogWithPP xmobarPP'
97 , modMask = mod4Mask 135 , modMask = mod4Mask
98 , keys = \conf -> hKeysMod host conf $ myKeys' conf 136 , keys = \conf -> hKeysMod host conf $ myKeys' conf host
99 , workspaces = take (length numKeys) $ map (hWsp host) [1..] 137 , workspaces = take (length numKeys) $ map wsp [1..]
100 , startupHook = assimilateKeychain >> (sequence autostart) >> (setDefaultCursor xC_left_ptr) >> banishScreen LowerRight >> return () 138 , startupHook = assimilateKeychain >> (sequence autostart) >> (setDefaultCursor xC_left_ptr) >> banishScreen LowerRight >> return ()
101 , normalBorderColor = "#202020" 139 , normalBorderColor = "#202020"
102 , focusedBorderColor = "white" 140 , focusedBorderColor = "white"
103 } 141 }
104 layout' = hLayoutMod host $ defaultLayouts 142 wsp = hWsp host
143 -- We canĀ“t define per-host layout modifiers because we lack dependent types
144 layout' = onHost "skadhi" ( onWorkspace (wsp 1) (noBorders Full ||| withIM (1%5) (Title "Buddy List") (tabbedLayout tabbedBottomAlways)) $
145 onWorkspace (wsp 10) (noBorders Full) $
146 onWorkspace (wsp 2) (noBorders Full ||| tabbedLayout tabbedBottomAlways) $
147 onWorkspace (wsp 5) (tabbedLayout tabbedBottomAlways) $
148 onWorkspace (wsp 8) (withIM (1%5) (Title "Friends") (tabbedLayout tabbedBottomAlways)) $
149 defaultLayouts
150 ) $
151 onHost "vali" ( onWorkspace (wsp 2) (noBorders Full ||| tabbedLayout tabbedBottomAlways) $
152 defaultLayouts
153 ) $
154 defaultLayouts
105 defaultLayouts = spiralWithDir East CW (1 % 2) ||| tabbedLayout tabbedBottom ||| noBorders Full ||| simplestFloat 155 defaultLayouts = spiralWithDir East CW (1 % 2) ||| tabbedLayout tabbedBottom ||| noBorders Full ||| simplestFloat
106 tabbedLayout t = renamed [Replace "Tabbed"] $ reflectHoriz $ t CustomShrink $ tabbedTheme
107 tabbedTheme = defaultTheme { activeColor = "black"
108 , inactiveColor = "black"
109 , urgentColor = "black"
110 , activeBorderColor = "white"
111 , inactiveBorderColor = "#202020"
112 , urgentBorderColor = "#bb0000"
113 , activeTextColor = "white"
114 , inactiveTextColor = "white"
115 , urgentTextColor = "white"
116 , decoHeight = 16
117 }
118 xmobarPP' = xmobarPP { ppOutput = hPutStrLn xmobarProc 156 xmobarPP' = xmobarPP { ppOutput = hPutStrLn xmobarProc
119 , ppTitle = shorten 50 157 , ppTitle = shorten 50
120 , ppSort = (liftM2 (.)) getSortByIndex $ return scratchpadFilterOutWorkspace 158 , ppSort = (liftM2 (.)) getSortByIndex $ return scratchpadFilterOutWorkspace
@@ -129,10 +167,13 @@ main = do
129 xmonad $ myConfig 167 xmonad $ myConfig
130 168
131autostart = [ spawnKeychain 169autostart = [ spawnKeychain
132 , safeSpawn "urxvtd" ["-q", "-f", "-o"] 170 , spawnOnce "urxvtd -o"
133 ] 171 ]
134 172
135spawnKeychain = runInTerm "" "keychain ~/.ssh/id_ecdsa ~/.ssh/id_rsa" 173spawnKeychain = do
174 home <- liftIO getHomeDirectory
175 let keys = map ((home </>) . ("/.ssh/id_" ++)) ["ed25519", "ecdsa", "rsa"]
176 safeSpawn "urxvt" $ ["-title", "keysetup", "-e", "keychain"] ++ keys
136 177
137assimilateKeychain :: X () 178assimilateKeychain :: X ()
138assimilateKeychain = liftIO $ assimilateKeychain' >> return () 179assimilateKeychain = liftIO $ assimilateKeychain' >> return ()
@@ -183,7 +224,7 @@ sshOverrides = map (\h -> mkOverride { oHost = h, oCommand = moshCmd . inTmux }
183 [ "galois", "galois.praseodym.org" 224 [ "galois", "galois.praseodym.org"
184 ] 225 ]
185 226
186myKeys' conf = Map.fromList $ 227myKeys' conf host = Map.fromList $
187 -- launch a terminal 228 -- launch a terminal
188 [ ((modm, xK_Return), spawn $ (XMonad.terminal conf) ++ " -e tmux") 229 [ ((modm, xK_Return), spawn $ (XMonad.terminal conf) ++ " -e tmux")
189 , ((modm .|. controlMask, xK_Return), scratchpadSpawnActionCustom $ (XMonad.terminal conf) ++ " -name scratchpad -title scratchpad -e tmux") 230 , ((modm .|. controlMask, xK_Return), scratchpadSpawnActionCustom $ (XMonad.terminal conf) ++ " -name scratchpad -title scratchpad -e tmux")
@@ -269,7 +310,7 @@ myKeys' conf = Map.fromList $
269 ] 310 ]
270 ++ 311 ++
271 [((m .|. modm .|. controlMask, k), screenWorkspace i >>= (flip whenJust) (windows . f)) 312 [((m .|. modm .|. controlMask, k), screenWorkspace i >>= (flip whenJust) (windows . f))
272 | (i, k) <- zip [0..] [xK_g, xK_c, xK_r, xK_l] 313 | (i, k) <- zip (hScreens host) [xK_g, xK_c, xK_r, xK_l]
273 , (f, m) <- [(W.view, 0), (W.shift, shiftMask)] 314 , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]
274 ] 315 ]
275 where 316 where