diff options
Diffstat (limited to '.xmonad')
-rw-r--r-- | .xmonad/xmonad.hs | 107 |
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) | |||
14 | import XMonad.Layout.Spiral | 14 | import XMonad.Layout.Spiral |
15 | import Data.Ratio | 15 | import Data.Ratio |
16 | import Data.List | 16 | import Data.List |
17 | import Data.Maybe (fromMaybe, listToMaybe) | 17 | import Data.Maybe (fromMaybe, listToMaybe, catMaybes) |
18 | import XMonad.Layout.Tabbed | 18 | import XMonad.Layout.Tabbed |
19 | import XMonad.Prompt | 19 | import XMonad.Prompt |
20 | import XMonad.Util.Scratchpad | 20 | import XMonad.Util.Scratchpad |
@@ -25,6 +25,7 @@ import XMonad.Layout.PerWorkspace | |||
25 | import XMonad.Layout.SimplestFloat | 25 | import XMonad.Layout.SimplestFloat |
26 | import XMonad.Layout.Renamed | 26 | import XMonad.Layout.Renamed |
27 | import XMonad.Layout.Reflect | 27 | import XMonad.Layout.Reflect |
28 | import XMonad.Layout.OnHost | ||
28 | import System.Process | 29 | import System.Process |
29 | import System.Directory (removeFile) | 30 | import System.Directory (removeFile) |
30 | import System.Posix.Files | 31 | import System.Posix.Files |
@@ -39,6 +40,9 @@ import Control.Monad (when) | |||
39 | import Graphics.X11.ExtraTypes.XF86 | 40 | import Graphics.X11.ExtraTypes.XF86 |
40 | import XMonad.Util.Cursor | 41 | import XMonad.Util.Cursor |
41 | import XMonad.Actions.Warp | 42 | import XMonad.Actions.Warp |
43 | import XMonad.Util.SpawnOnce | ||
44 | import System.Directory | ||
45 | import System.FilePath | ||
42 | 46 | ||
43 | import XMonad.Layout.IM | 47 | import XMonad.Layout.IM |
44 | 48 | ||
@@ -47,44 +51,78 @@ import XMonad.Prompt.MySsh | |||
47 | 51 | ||
48 | import Network.HostName | 52 | import Network.HostName |
49 | 53 | ||
54 | import Control.Applicative ((<$>)) | ||
55 | |||
50 | type KeyMap = Map (ButtonMask, KeySym) (X ()) | 56 | type KeyMap = Map (ButtonMask, KeySym) (X ()) |
51 | 57 | ||
52 | data Host l1 l2 = Host | 58 | data 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 | ||
60 | defaultHost = Host { hName = "unkown" | 67 | defaultHost = 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) | 75 | hostFromName :: HostName -> Host |
68 | hostFromName h@("vali") = defaultHost { hName = h | 76 | hostFromName 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 | ||
80 | hostFromName _ = defaultHost | 96 | hostFromName _ = defaultHost |
81 | 97 | ||
98 | wspFromMap workspaceNames = \i -> case Map.lookup i workspaceNames of | ||
99 | Just str -> show i ++ " " ++ str | ||
100 | Nothing -> show i | ||
101 | |||
102 | coWspFromMap workspaceNames = \str -> case filter ((== str) . snd) $ Map.toList workspaceNames of | ||
103 | [] -> Nothing | ||
104 | [(i, _)] -> Just $ wspFromMap workspaceNames i | ||
105 | _ -> Nothing | ||
106 | |||
82 | spawnModifiers = [0, controlMask, shiftMask .|. controlMask] | 107 | spawnModifiers = [0, controlMask, shiftMask .|. controlMask] |
83 | spawnBindings conf (k, cmds) = zipWith (\m cmd -> ((modm .|. mod1Mask .|. m, k), spawn cmd)) spawnModifiers cmds | 108 | spawnBindings 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 | ||
87 | manageScratchTerm = resource =? "scratchpad" -?> doRectFloat $ RationalRect (1 % 16) (1 % 16) (7 % 8) (7 % 8) | 112 | manageScratchTerm = (resource =? "scratchpad" <||> resource =? "keysetup") -?> doRectFloat $ RationalRect (1 % 16) (1 % 16) (7 % 8) (7 % 8) |
113 | |||
114 | tabbedLayout t = renamed [Replace "Tabbed"] $ reflectHoriz $ t CustomShrink $ tabbedTheme | ||
115 | tabbedTheme = 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 | ||
89 | main = do | 127 | main = 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 | ||
131 | autostart = [ spawnKeychain | 169 | autostart = [ spawnKeychain |
132 | , safeSpawn "urxvtd" ["-q", "-f", "-o"] | 170 | , spawnOnce "urxvtd -o" |
133 | ] | 171 | ] |
134 | 172 | ||
135 | spawnKeychain = runInTerm "" "keychain ~/.ssh/id_ecdsa ~/.ssh/id_rsa" | 173 | spawnKeychain = 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 | ||
137 | assimilateKeychain :: X () | 178 | assimilateKeychain :: X () |
138 | assimilateKeychain = liftIO $ assimilateKeychain' >> return () | 179 | assimilateKeychain = 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 | ||
186 | myKeys' conf = Map.fromList $ | 227 | myKeys' 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 |