xmonad-config/lib/StatusBar.hs

70 lines
2.1 KiB
Haskell
Raw Normal View History

{-# LANGUAGE FlexibleContexts #-}
module StatusBar (
StatusBar.modify
) where
import Data.List
import Data.Monoid
import Solarized as S
import XMonad.Core
import XMonad.Hooks.DynamicBars (dynStatusBarStartup,dynStatusBarEventHook,multiPP)
import XMonad.Hooks.DynamicLog
import XMonad.ManageHook
import XMonad.Util.Run
-- Type constructors
import GHC.IO.Handle (Handle)
modify :: XConfig l -> XConfig l
modify conf = conf
{ startupHook = do
startupHook conf
dynStatusBarStartup runXmobar killXmobar
, handleEventHook = handleEventHook conf <+> dynStatusBarEventHook runXmobar killXmobar
, logHook = do
logHook conf
multiPP currentPP otherPP
}
runXmobar :: ScreenId -> IO Handle
runXmobar (S id) = spawnPipe
$ "/run/current-system/sw/bin/xmobar --screen="
<> show id
<> " /home/eeva/.xmonad/xmobarrc"
killXmobar :: IO ()
-- killXmobar = spawn "/run/current-system/sw/bin/pkill xmobar"
killXmobar = return ()
otherPP = currentPP
{ ppCurrent = xmobarColor S.foreground S.background
, ppVisible = xmobarColor S.foreground S.background
, ppHidden = xmobarColor S.foreground S.background
, ppHiddenNoWindows = xmobarColor S.backgroundhl S.background
}
currentPP = def
{ ppCurrent = xmobarColor' S.orange
, ppVisible = xmobarColor' S.yellow -- other screen
, ppHidden = xmobarColor' S.foreground -- other workspaces with windows
, ppHiddenNoWindows = xmobarColor' S.foregroundll -- other workspaces
, ppSep = " "
, ppWsSep = " "
, ppLayout = printLayout
, ppTitle = printTitle
}
where xmobarColor' fg = xmobarColor fg S.base03
printLayout s | "Mirror ResizableTall" `isSuffixOf` s = "[ — ]"
printLayout s | "ResizableTall" `isSuffixOf` s = "[ | ]"
printLayout "Full" = "[ F ]"
printLayout l = "[" ++ l ++ "]"
printTitle t = let t' = shorten 120 t
in xmobarColor' S.foregroundll "« "
++ xmobarColor' S.foregroundhl t'
++ xmobarColor' S.foregroundll " »"