ENH use theme vars in xinerama xmobar thingy

This commit is contained in:
Nathan Dwarshuis 2020-03-16 14:03:02 -04:00
parent 7787006621
commit c720cbc39a
1 changed files with 13 additions and 12 deletions

View File

@ -5,7 +5,7 @@ module Main (main) where
import ACPI import ACPI
import SendXMsg import SendXMsg
import Theme import qualified Theme as T
import Control.Monad (mapM_, forM_, void, when) import Control.Monad (mapM_, forM_, void, when)
@ -107,7 +107,7 @@ myLayouts = onWorkspace myVMWorkspace (noBorders Full)
-- $ onWorkspace myGimpWorkspace gimpLayout -- $ onWorkspace myGimpWorkspace gimpLayout
$ tall ||| single ||| full $ tall ||| single ||| full
where where
addTopBar = noFrillsDeco shrinkText tabbedTheme addTopBar = noFrillsDeco shrinkText T.tabbedTheme
tall = named "Tall" tall = named "Tall"
$ avoidStruts $ avoidStruts
$ addTopBar $ addTopBar
@ -117,7 +117,7 @@ myLayouts = onWorkspace myVMWorkspace (noBorders Full)
-- $ addTopBar -- $ addTopBar
$ avoidStruts $ avoidStruts
$ noBorders $ noBorders
$ tabbedAlways shrinkText tabbedTheme $ tabbedAlways shrinkText T.tabbedTheme
full = named "Full" full = named "Full"
$ noBorders Full $ noBorders Full
-- gimpLayout = named "Gimp Layout" -- gimpLayout = named "Gimp Layout"
@ -136,24 +136,25 @@ myLoghook h = withWindowSet $ io . hPutStrLn h . myWindowSetXinerama
myWindowSetXinerama ws = wsString ++ sep ++ layout myWindowSetXinerama ws = wsString ++ sep ++ layout
where where
wsString = xmobarColor "#444444" "" $ onscreen ++ offscreen' wsString = xmobarColor T.backdropFgColor "" $ onscreen ++ offscreen'
offscreen' = if offscreen == "" then "" else " " ++ offscreen offscreen' = if null offscreen then "" else " " ++ offscreen
sep = xmobarColor "#888888" "" " : " sep = xmobarColor T.backdropFgColor "" " : "
onscreen = xmobarColor "#5574ad" visColor onscreen = xmobarColor hilightFgColor hilightBgColor
$ wrap " " " " $ wrap " " " "
$ unwords $ unwords
$ map (fmtTags . W.tag . W.workspace) $ map (fmtTags . W.tag . W.workspace)
. sortBy compareXCoord . sortBy compareXCoord
$ W.current ws : W.visible ws $ W.current ws : W.visible ws
fmtTags t = if t == W.currentTag ws fmtTags t = if t == W.currentTag ws
then xmobarColor "#2c2c2c" visColor t then xmobarColor T.fgColor hilightBgColor t
else t else t
offscreen = unwords offscreen = unwords
$ map W.tag $ map W.tag
. filter (isJust . W.stack) . filter (isJust . W.stack)
. sortOn W.tag . sortOn W.tag
$ W.hidden ws $ W.hidden ws
visColor = "#8fc7ff" hilightBgColor = "#8fc7ff"
hilightFgColor = T.blend' 0.5 hilightBgColor T.fgColor
layout = description . W.layout . W.workspace . W.current $ ws layout = description . W.layout . W.workspace . W.current $ ws
compareXCoord s0 s1 = compare x0 x1 compareXCoord s0 s1 = compare x0 x1
where where
@ -208,7 +209,7 @@ myEventHook ClientMessageEvent { ev_message_type = t, ev_data = d }
let acpiTag = readMaybe tag :: Maybe ACPIEvent let acpiTag = readMaybe tag :: Maybe ACPIEvent
forM_ acpiTag $ \case forM_ acpiTag $ \case
Power -> myPowerPrompt Power -> myPowerPrompt
Sleep -> confirmPrompt promptTheme "suspend?" runSuspend Sleep -> confirmPrompt T.promptTheme "suspend?" runSuspend
LidClose -> do LidClose -> do
status <- io isDischarging status <- io isDischarging
forM_ status $ \s -> runScreenLock >> when s runSuspend forM_ status $ \s -> runScreenLock >> when s runSuspend
@ -253,7 +254,7 @@ myPowerPrompt = mkXPrompt PowerPrompt conf comps
. (`lookup` commands) . (`lookup` commands)
where where
comps = mkComplFunFromList' (map fst commands) comps = mkComplFunFromList' (map fst commands)
conf = promptTheme conf = T.promptTheme
commands = commands =
[ ("poweroff", runPowerOff) [ ("poweroff", runPowerOff)
, ("suspend", runScreenLock >> runSuspend) , ("suspend", runScreenLock >> runSuspend)
@ -262,7 +263,7 @@ myPowerPrompt = mkXPrompt PowerPrompt conf comps
] ]
myQuitPrompt :: X () myQuitPrompt :: X ()
myQuitPrompt = confirmPrompt promptTheme "quit?" $ io exitSuccess myQuitPrompt = confirmPrompt T.promptTheme "quit?" $ io exitSuccess
-- shell commands -- shell commands