From 888704927fce43a8caa932d6b3bb0158bd78bf0d Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 3 Jul 2015 23:41:04 +0200 Subject: Further work on xmonad.hs (host dependent configs) --- .xmonad/xmonad.hs | 49 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/.xmonad/xmonad.hs b/.xmonad/xmonad.hs index 98352d3..241785a 100644 --- a/.xmonad/xmonad.hs +++ b/.xmonad/xmonad.hs @@ -31,6 +31,7 @@ import System.FilePath (()) import Control.Concurrent import System.Posix.Process (getProcessID) import System.IO.Error +import System.IO import XMonad.Hooks.ManageHelpers hiding (CW) import XMonad.StackSet (RationalRect (..)) import Control.Monad (when) @@ -43,27 +44,52 @@ import XMonad.Layout.IM import XMonad.Prompt.MyShell import XMonad.Prompt.MySsh -wsp :: Int -> WorkspaceId -wsp i = case Map.lookup i workspaceNames of - Just str -> (show i) ++ " " ++ str - Nothing -> (show i) -wsps = map wsp +import Network.HostName + +data Host l1 l2 = Host + { hName :: HostName + , hManageHook :: ManageHook + , hWsp :: Integer -> WorkspaceId + , hLayoutMod :: l1 -> l2 + } + +defaultHost = Host { hName = "unkown" + , hManageHook = composeOne [manageScratchTerm] + , hWsp = show + , hLayoutMod = id + } + +--hostFromName :: (LayoutClass l1 a, LayoutClass l2 a) => HostName -> Host (l1 a) (l2 a) +hostFromName h@("vali") = defaultHost { hName = h + , hManageHook = hManageHook defaultHost + , hWsp = \i -> case Map.lookup i workspaceNames of + Just str -> show i ++ " " ++ str + Nothing -> show i + , hLayoutMod = id + } + where + workspaceNames = Map.fromList [ (1, "web") + ] +hostFromName _ = defaultHost + +manageScratchTerm = resource =? "scratchpad" -?> doRectFloat $ RationalRect (1 % 16) (1 % 16) (7 % 8) (7 % 8) main = do xmobarProc <- spawnPipe "xmobar" + host <- getHostName >>= return . hostFromName let myConfig = defaultConfig { - manageHook = manageDocks <+> manageHook' + manageHook = manageDocks <+> hManageHook host , terminal = "urxvtc" , layoutHook = smartBorders $ avoidStruts layout' , logHook = dynamicLogWithPP xmobarPP' , modMask = mod4Mask , keys = myKeys' - , workspaces = take (length numKeys) workspaces' + , workspaces = take (length numKeys) $ map (hWsp host) [1..] , startupHook = assimilateKeychain >> (sequence autostart) >> (setDefaultCursor xC_left_ptr) >> banishScreen LowerRight >> return () , normalBorderColor = "#202020" , focusedBorderColor = "white" } - layout' = defaultLayouts + layout' = hLayoutMod host $ defaultLayouts defaultLayouts = spiralWithDir East CW (1 % 2) ||| tabbedLayout tabbedBottom ||| noBorders Full ||| simplestFloat tabbedLayout t = renamed [Replace "Tabbed"] $ reflectHoriz $ t CustomShrink $ tabbedTheme tabbedTheme = defaultTheme { activeColor = "black" @@ -118,13 +144,6 @@ assimilateKeychain' = tryIOError $ do numKeys = [xK_parenleft, xK_parenright, xK_braceright, xK_plus, xK_braceleft, xK_bracketright, xK_bracketleft, xK_exclam, xK_equal, xK_asterisk] -workspaces' = wsps [1..] -workspaceNames = Map.fromList - [] - -manageHook' = composeOne - [] - instance Shrinker CustomShrink where shrinkIt _ "" = [""] shrinkIt s cs = cs : shrinkIt s ((reverse . drop 4 . reverse $ cs) ++ "...") -- cgit v1.2.3