diff --git a/system/desktop/home-manager/xmonad.nix b/system/desktop/home-manager/xmonad.nix index ca0d50a..ed06533 100644 --- a/system/desktop/home-manager/xmonad.nix +++ b/system/desktop/home-manager/xmonad.nix @@ -30,5 +30,8 @@ in { home.file.".xmonad/lib/FloatKeys.hs".source = ./xmonad/FloatKeys.hs; home.file.".xmonad/lib/TabbedFix.hs".source = ./xmonad/TabbedFix.hs; home.file.".xmonad/lib/BoringWindows.hs".source = ./xmonad/BoringWindows.hs; + + home.file.".xmonad/xmonad.cabal".source = ./xmonad/palos-xmonad.cabal; + home.file.".xmonad/Main.hs".source = ./xmonad/Main.hs; }; } diff --git a/system/desktop/home-manager/xmonad/Main.hs b/system/desktop/home-manager/xmonad/Main.hs index 6a4a37d..5114dcd 100644 --- a/system/desktop/home-manager/xmonad/Main.hs +++ b/system/desktop/home-manager/xmonad/Main.hs @@ -73,9 +73,6 @@ nonSelectionColor = Solarized.base02 -- http://hackage.haskell.org/package/xmonad-contrib-0.15/docs/XMonad-Layout-Tabbed.html#t:Theme - --- todo : when there is only one window there should not be a decoration bar, when there are 2 there should be a decoration bar --- ResizableTall is same as Tall but has resizable rightside window myLayout = (windowConfiguration $ myTabbed $ mySubLayout $ boringWindows resizeableTall) ||| noBorders Full -- needed for rebuild sometimes -- myLayout = dwmStyle shrinkText def ( layoutHook def ) ||| noBorders Full @@ -90,9 +87,9 @@ myLayout = (windowConfiguration $ myTabbed $ mySubLayout $ boringWindows resize windowConfiguration = configurableNavigation noNavigateBorders - myTabbed x = smartBorders $ addTabsAlways shrinkText tabDecoration x + myTabbed x = smartBorders $ addTabsAlways shrinkText tabDecoration x - mySubLayout x = subLayout [] Simplest x + mySubLayout = subLayout [] Simplest tabDecoration = def { activeColor = selectionColor , activeBorderColor = selectionColor diff --git a/system/desktop/home-manager/xmonad/TabbedFix.hs b/system/desktop/home-manager/xmonad/TabbedFix.hs index 239a409..3f1d1ee 100644 --- a/system/desktop/home-manager/xmonad/TabbedFix.hs +++ b/system/desktop/home-manager/xmonad/TabbedFix.hs @@ -1,25 +1,24 @@ --- A fix to refocus windows in a sublayout --- copied and manipulated from https://github.com/wz1000/xmonad-config/blob/master/xmonad.hs --- thx wz1000 - -{-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE TypeSynonymInstances #-} + module TabbedFix (historyLayout, runAllPending) where -import XMonad -import qualified XMonad.StackSet as W -import qualified Data.List as L -import qualified XMonad.Util.ExtensibleState as ES -import Control.DeepSeq (force) -import XMonad.Layout.LayoutModifier (LayoutModifier, ModifiedLayout(ModifiedLayout), modifyLayout) +import Control.DeepSeq (force) +import qualified Data.List as L +import XMonad +import XMonad.Layout.LayoutModifier (LayoutModifier, + ModifiedLayout (ModifiedLayout), + modifyLayout) +import qualified XMonad.StackSet as W +import qualified XMonad.Util.ExtensibleState as ES + +newtype PendingActions = + PendingActions [X ()] -newtype PendingActions = PendingActions { getPending :: [X()] } instance ExtensionClass PendingActions where initialValue = PendingActions [] - --- Add action to stack addAction :: X () -> X () addAction x = ES.modify (\(PendingActions xs) -> PendingActions (x:xs)) @@ -43,46 +42,49 @@ historyLayout :: l Window -> ModifiedLayout FocusLayout l Window historyLayout = ModifiedLayout FocusLayout instance LayoutModifier FocusLayout Window where - modifyLayout fh ws rct = do - wold <- getFocused + modifyLayout _ workspace rectangle = do + oldWindow <- getFocused history <- getFocusHistory <$> ES.get - wnew <- windowHistoryHook wold - case wnew of - Nothing -> runLayout ws rct - Just w -> do - let oldstack = W.stack ws + newWindow <- windowHistoryHook oldWindow + case newWindow of + Nothing -> runLayout workspace rectangle + Just window -> do + let oldstack = W.stack workspace let mw = L.find (`elem` W.integrate' oldstack) history - let newstack = if (w `elem` (W.integrate' oldstack)) - then until ((w==) . W.focus) W.focusUp' <$> oldstack - else case mw of - Just w -> until ((w==) . W.focus) W.focusUp' <$> oldstack - Nothing -> oldstack - modifyWindowSet (W.focusWindow w) + let newstack = + if window `elem` (W.integrate' oldstack) + then until ((window ==) . W.focus) W.focusUp' <$> oldstack + else case mw of + Just window' -> + until ((window' ==) . W.focus) W.focusUp' <$> oldstack + Nothing -> oldstack + modifyWindowSet (W.focusWindow window) addAction $ do - maybe (return ()) makeBorderNormal wold + maybe (return ()) makeBorderNormal oldWindow windows id - runLayout ws{W.stack = newstack} rct + runLayout workspace {W.stack = newstack} rectangle +windowHistoryHook :: Maybe Window -> X (Maybe Window) windowHistoryHook Nothing = return Nothing -windowHistoryHook (Just w) = do - hist <- getFocusHistory <$> ES.get - curws <- gets $ W.index . windowset - withWindowSet $ \allws -> - case hist of +windowHistoryHook (Just window') = do + history <- getFocusHistory <$> ES.get + currentWindowSet <- gets $ W.index . windowset + withWindowSet $ \allWindows -> + case history of [] -> do - ES.put $ FocusHistory[w] + ES.put $ FocusHistory [window'] return Nothing (prev:xs) - | prev == w -> return Nothing + | prev == window' -> return Nothing -- Previous focus was removed from ws, focus on previous existing window in current ws - | not (prev `elem` curws) -> do - let hist' = filter (`W.member` allws) xs - ES.put (FocusHistory $ force $ hist') - return $ L.find (\x -> x `elem` curws ) hist' + | prev `notElem` currentWindowSet -> do + let history' = filter (`W.member` allWindows) xs + ES.put (FocusHistory $ force history') + return $ L.find (`elem` currentWindowSet) history' -- Add current focus to history - | otherwise -> do - ES.put $ FocusHistory $ force $ (w:L.delete w hist) - return Nothing + | otherwise -> do + ES.put $ FocusHistory $ force $ window' : L.delete window' history + return Nothing makeBorderRed :: Window -> X () makeBorderRed w = @@ -90,10 +92,12 @@ makeBorderRed w = setWindowBorder d w 0xff0000 -- wz1000: palo: btw, you will need to change the color in makeBorderNormal to your unfocused border color +makeBorderNormal :: Window -> X () makeBorderNormal w = withDisplay $ \d -> io $ do setWindowBorder d w 0x2b2b2b +makeBorderFocused :: Window -> X () makeBorderFocused w = withDisplay $ \d -> io $ do setWindowBorder d w 0xcccccc