[XMonad] Reindent a bunch of definitions

This commit is contained in:
Ivan Malison 2016-11-25 18:48:14 -08:00
parent fa7c46b764
commit 6d17f96ecf
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8

View File

@ -49,18 +49,20 @@ import XMonad.Util.NamedScratchpad
(NamedScratchpad(NS), nonFloating, namedScratchpadAction) (NamedScratchpad(NS), nonFloating, namedScratchpadAction)
import XMonad.Util.NamedWindows (getName) import XMonad.Util.NamedWindows (getName)
main = xmonad $ def main =
xmonad $ def
{ modMask = mod4Mask { modMask = mod4Mask
, terminal = "urxvt" , terminal = "urxvt"
, manageHook = manageDocks <+> myManageHook <+> manageHook def , manageHook = manageDocks <+> myManageHook <+> manageHook def
, layoutHook = myLayoutHook , layoutHook = myLayoutHook
, logHook = toggleFadeInactiveLogHook 0.9 +++ ewmhWorkspaceNamesLogHook , logHook = toggleFadeInactiveLogHook 0.9 +++ ewmhWorkspaceNamesLogHook
, handleEventHook = docksEventHook <+> fullscreenEventHook +++ , handleEventHook =
ewmhDesktopsEventHook +++ pagerHintsEventHook +++ docksEventHook <+> fullscreenEventHook +++
followIfNoMagicFocus ewmhDesktopsEventHook +++ pagerHintsEventHook +++ followIfNoMagicFocus
, startupHook = myStartup +++ ewmhWorkspaceNamesLogHook , startupHook = myStartup +++ ewmhWorkspaceNamesLogHook
, keys = customKeys (const []) addKeys , keys = customKeys (const []) addKeys
} where }
where
x +++ y = mappend y x x +++ y = mappend y x
@ -127,7 +129,8 @@ myStartup = spawn "systemctl --user start wm.target"
-- Manage hook -- Manage hook
myManageHook = composeAll . concat $ myManageHook =
composeAll . concat $
[ [transmissionSelector --> doShift "5"] [ [transmissionSelector --> doShift "5"]
-- Hangouts being on a separate workspace freezes chrome -- Hangouts being on a separate workspace freezes chrome
-- , [ hangoutsSelector --> doShift "2"] -- , [ hangoutsSelector --> doShift "2"]
@ -137,8 +140,8 @@ myManageHook = composeAll . concat $
unmodifyLayout (ModifiedLayout _ x') = x' unmodifyLayout (ModifiedLayout _ x') = x'
selectLimit = DM.menuArgs "rofi" ["-dmenu", "-i"] ["2", "3", "4"] >>= selectLimit =
(setLimit . read) DM.menuArgs "rofi" ["-dmenu", "-i"] ["2", "3", "4"] >>= (setLimit . read)
data MyToggles = LIMIT data MyToggles = LIMIT
| GAPS | GAPS
@ -153,26 +156,29 @@ instance Transformer MyToggles Window where
myToggles = [LIMIT, GAPS, MAGICFOCUS] myToggles = [LIMIT, GAPS, MAGICFOCUS]
otherToggles = [NBFULL, MIRROR] otherToggles = [NBFULL, MIRROR]
followIfNoMagicFocus = followOnlyIf $ fmap (fromMaybe False . fmap not) $ followIfNoMagicFocus =
isToggleActive MAGICFOCUS followOnlyIf $ maybe False not <$> isToggleActive MAGICFOCUS
togglesMap = fmap M.fromList $ sequence $ togglesMap =
fmap M.fromList $ sequence $
map toggleTuple myToggles ++ map toggleTuple otherToggles map toggleTuple myToggles ++ map toggleTuple otherToggles
where where
toggleTuple toggle = fmap (\str -> (str, Toggle toggle)) toggleTuple toggle =
(toggleToStringWithState toggle) fmap (\str -> (str, Toggle toggle)) (toggleToStringWithState toggle)
toggleStateToString s = case s of
toggleStateToString s =
case s of
Just True -> "ON" Just True -> "ON"
Just False -> "OFF" Just False -> "OFF"
Nothing -> "N/A" Nothing -> "N/A"
toggleToStringWithState :: (Transformer t Window, Show t) => t -> X String toggleToStringWithState :: (Transformer t Window, Show t) => t -> X String
toggleToStringWithState toggle = toggleToStringWithState toggle =
(printf "%s (%s)" (show toggle) . toggleStateToString) <$> (printf "%s (%s)" (show toggle) . toggleStateToString) <$> isToggleActive toggle
isToggleActive toggle
selectToggle = togglesMap >>= DM.menuMapArgs "rofi" ["-dmenu", "-i"] >>= selectToggle =
togglesMap >>= DM.menuMapArgs "rofi" ["-dmenu", "-i"] >>=
flip whenJust sendMessage flip whenJust sendMessage
toggleInState :: (Transformer t Window) => t -> Maybe Bool -> X Bool toggleInState :: (Transformer t Window) => t -> Maybe Bool -> X Bool
@ -188,8 +194,8 @@ setToggleActive = (void .) . setToggleActive'
deactivateFull = setToggleActive NBFULL False deactivateFull = setToggleActive NBFULL False
toggleOr toggle toState action = setToggleActive' toggle toState >>= toggleOr toggle toState action =
((`when` action) . not) setToggleActive' toggle toState >>= ((`when` action) . not)
deactivateFullOr = toggleOr NBFULL False deactivateFullOr = toggleOr NBFULL False
deactivateFullAnd action = sequence_ [deactivateFull, action] deactivateFullAnd action = sequence_ [deactivateFull, action]
@ -206,7 +212,8 @@ layoutsStart layout = (layout, [Layout layout])
(|||!) (joined, layouts) newLayout = (|||!) (joined, layouts) newLayout =
(joined ||| newLayout, layouts ++ [Layout newLayout]) (joined ||| newLayout, layouts ++ [Layout newLayout])
layoutInfo = layoutsStart (rename "Columns" $ multiCol [1, 1] 2 0.01 (-0.5)) |||! layoutInfo =
layoutsStart (rename "Columns" $ multiCol [1, 1] 2 0.01 (-0.5)) |||!
rename "Large Main" (Tall 1 (3 / 100) (3 / 4)) |||! rename "Large Main" (Tall 1 (3 / 100) (3 / 4)) |||!
rename "2 Columns" (Tall 1 (3 / 100) (1 / 2)) |||! rename "2 Columns" (Tall 1 (3 / 100) (1 / 2)) |||!
Accordion Accordion
@ -215,13 +222,15 @@ layoutList = snd layoutInfo
layoutNames = [description layout | layout <- layoutList] layoutNames = [description layout | layout <- layoutList]
selectLayout = DM.menuArgs "rofi" ["-dmenu", "-i"] layoutNames >>= selectLayout =
DM.menuArgs "rofi" ["-dmenu", "-i"] layoutNames >>=
(sendMessage . JumpToLayout) (sendMessage . JumpToLayout)
myLayoutHook = avoidStruts . minimize . boringAuto . mkToggle1 MIRROR .
mkToggle1 LIMIT . mkToggle1 GAPS . mkToggle1 MAGICFOCUS . myLayoutHook =
mkToggle1 NBFULL . workspaceNamesHook . smartBorders . noBorders $ avoidStruts . minimize . boringAuto . mkToggle1 MIRROR . mkToggle1 LIMIT .
fst layoutInfo mkToggle1 GAPS . mkToggle1 MAGICFOCUS . mkToggle1 NBFULL . workspaceNamesHook .
smartBorders . noBorders $ fst layoutInfo
-- WindowBringer -- WindowBringer
@ -379,26 +388,29 @@ restoreOrMinimizeOtherClasses = withLastMinimized' $
-- Use greedyView to switch to the correct workspace, and then focus on the -- Use greedyView to switch to the correct workspace, and then focus on the
-- appropriate window within that workspace. -- appropriate window within that workspace.
greedyFocusWindow w ws = W.focusWindow w $ W.greedyView greedyFocusWindow w ws =
(fromMaybe (W.currentTag ws) $ W.findTag w ws) ws W.focusWindow w $
W.greedyView (fromMaybe (W.currentTag ws) $ W.findTag w ws) ws
shiftThenView i = W.greedyView i . W.shift i shiftThenView i = W.greedyView i . W.shift i
shiftToEmptyAndView = doTo Next EmptyWS DWO.getSortByOrder (windows . shiftThenView)
greedyBringWindow w = greedyFocusWindow w . bringWindow w greedyBringWindow w = greedyFocusWindow w . bringWindow w
shiftToEmptyAndView =
doTo Next EmptyWS DWO.getSortByOrder (windows . shiftThenView)
swapFocusedWith w ws = W.modify' (swapFocusedWith' w) (W.delete' w ws) swapFocusedWith w ws = W.modify' (swapFocusedWith' w) (W.delete' w ws)
swapFocusedWith' w (W.Stack current ls rs) = W.Stack w ls (rs ++ [current]) swapFocusedWith' w (W.Stack current ls rs) = W.Stack w ls (rs ++ [current])
swapMinimizeStateAfter action = withFocused $ \originalWindow -> do swapMinimizeStateAfter action =
withFocused $
\originalWindow -> do
_ <- action _ <- action
restoreFocus $ do restoreFocus $
maybeUnminimizeFocused do maybeUnminimizeFocused
withFocused $ \newWindow -> withFocused $
when (newWindow /= originalWindow) \newWindow -> when (newWindow /= originalWindow) $ minimizeWindow originalWindow
$ minimizeWindow originalWindow
-- Named Scratchpads -- Named Scratchpads