REF make common xmobar directory

This commit is contained in:
Nathan Dwarshuis 2020-03-25 18:55:52 -04:00
parent 9879d7f43c
commit a9468ef3dd
7 changed files with 45 additions and 33 deletions

View File

@ -8,10 +8,11 @@ import qualified Theme as T
import Data.List
import Xmobar
import Xmobar.Common
import XMonad (getXMonadDir)
wrapColor :: String -> String -> String
wrapColor c s = "<fc=" ++ c ++ ">" ++ s ++ "</fc>"
-- wrapColor :: String -> String -> String
-- wrapColor c s = "<fc=" ++ c ++ ">" ++ s ++ "</fc>"
sep :: String
sep = wrapColor T.backdropFgColor " : "

View File

@ -54,13 +54,14 @@ import System.Process.Internals
import Text.Read (readMaybe)
import Xmobar.Common
import XMonad
import XMonad.Actions.CopyWindow
import XMonad.Actions.CycleWS
import XMonad.Actions.DynamicWorkspaces
import XMonad.Actions.PhysicalScreens
import XMonad.Actions.Volume
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
@ -170,17 +171,17 @@ myWindowSetXinerama
W.StackSet String (layout a1) a2 ScreenId ScreenDetail -> String
myWindowSetXinerama ws = wsString ++ sep ++ layout
where
wsString = xmobarColor T.backdropFgColor "" $ onscreen ++ offscreen'
wsString = wrapColorBg T.backdropFgColor "" $ onscreen ++ offscreen'
offscreen' = if null offscreen then "" else " " ++ offscreen
sep = xmobarColor T.backdropFgColor "" " : "
onscreen = xmobarColor hilightFgColor hilightBgColor
$ wrap " " " "
sep = wrapColorBg T.backdropFgColor "" " : "
onscreen = wrapColorBg hilightFgColor hilightBgColor
$ (\s -> " " ++ s ++ " ")
$ unwords
$ map (fmtTags . W.tag . W.workspace)
. sortBy compareXCoord
$ W.current ws : W.visible ws
fmtTags t = if t == W.currentTag ws
then xmobarColor T.fgColor hilightBgColor t
then wrapColorBg T.fgColor hilightBgColor t
else t
offscreen = unwords
$ map W.tag

9
lib/Xmobar/Common.hs Normal file
View File

@ -0,0 +1,9 @@
module Xmobar.Common where
import XMonad.Hooks.DynamicLog (xmobarColor)
wrapColor :: String -> String -> String
wrapColor fg = wrapColorBg fg ""
wrapColorBg :: String -> String -> String -> String
wrapColorBg = xmobarColor

View File

@ -7,6 +7,7 @@ import DBus
import DBus.Client
import Xmobar
import Xmobar.Common
data Bluetooth = Bluetooth (String, String, String) Int
deriving (Read, Show)
@ -30,6 +31,5 @@ instance Exec Bluetooth where
Right r -> fromVariant r
Left _ -> Nothing
fmtState = \case
Just s -> wrapColor text $ if s then colorOn else colorOff
Just s -> wrapColor (if s then colorOn else colorOff) text
Nothing -> "N/A"
wrapColor s c = "<fc=" ++ c ++ ">" ++ s ++ "</fc>"

View File

@ -8,8 +8,9 @@ import Control.Monad
import DBus.Screensaver
import Xmobar
import Xmobar.Common
data Screensaver = Screensaver (String, String, String)
newtype Screensaver = Screensaver (String, String, String)
deriving (Read, Show)
instance Exec Screensaver where
@ -20,7 +21,6 @@ instance Exec Screensaver where
forever (threadDelay 5000000)
where
fmtState = \case
Just s -> wrapColor text $ if s then colorOn else colorOff
Just s -> wrapColor (if s then colorOn else colorOff) text
Nothing -> "N/A"
wrapColor s c = "<fc=" ++ c ++ ">" ++ s ++ "</fc>"

View File

@ -7,6 +7,7 @@ import DBus
import DBus.Client
import Xmobar
import Xmobar.Common
data VPN = VPN (String, String, String) Int
deriving (Read, Show)
@ -30,6 +31,5 @@ instance Exec VPN where
Right r -> (fromVariant r :: Maybe String)
Left _ -> Nothing
fmtState = \case
Just s -> wrapColor text $ if s == "vpn" then colorOn else colorOff
Just s -> wrapColor (if s == "vpn" then colorOn else colorOff) text
Nothing -> "N/A"
wrapColor s c = "<fc=" ++ c ++ ">" ++ s ++ "</fc>"

View File

@ -15,6 +15,7 @@ library
, DBus.IntelBacklight
, DBus.Internal
, DBus.Screensaver
, Xmobar.Common
, Xmobar.Plugins.Bluetooth
, Xmobar.Plugins.IntelBacklight
, Xmobar.Plugins.Screensaver