diff --git a/bin/xmobar.hs b/bin/xmobar.hs
index 325ae06..40944df 100644
--- a/bin/xmobar.hs
+++ b/bin/xmobar.hs
@@ -1,17 +1,18 @@
-import Xmobar.Plugins.Bluetooth
-import Xmobar.Plugins.IntelBacklight
-import Xmobar.Plugins.Screensaver
-import Xmobar.Plugins.VPN
+import Xmobar.Plugins.Bluetooth
+import Xmobar.Plugins.IntelBacklight
+import Xmobar.Plugins.Screensaver
+import Xmobar.Plugins.VPN
-import qualified Theme as T
+import qualified Theme as T
-import Data.List
+import Data.List
-import Xmobar
-import XMonad (getXMonadDir)
+import Xmobar
+import Xmobar.Common
+import XMonad (getXMonadDir)
-wrapColor :: String -> String -> String
-wrapColor c s = "" ++ s ++ ""
+-- wrapColor :: String -> String -> String
+-- wrapColor c s = "" ++ s ++ ""
sep :: String
sep = wrapColor T.backdropFgColor " : "
diff --git a/bin/xmonad.hs b/bin/xmonad.hs
index 56ac358..862610e 100644
--- a/bin/xmonad.hs
+++ b/bin/xmonad.hs
@@ -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
diff --git a/lib/Xmobar/Common.hs b/lib/Xmobar/Common.hs
new file mode 100644
index 0000000..5d90471
--- /dev/null
+++ b/lib/Xmobar/Common.hs
@@ -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
diff --git a/lib/Xmobar/Plugins/Bluetooth.hs b/lib/Xmobar/Plugins/Bluetooth.hs
index 8bca35d..0608ff1 100644
--- a/lib/Xmobar/Plugins/Bluetooth.hs
+++ b/lib/Xmobar/Plugins/Bluetooth.hs
@@ -3,10 +3,11 @@
module Xmobar.Plugins.Bluetooth where
-import DBus
-import DBus.Client
+import DBus
+import DBus.Client
-import Xmobar
+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 = "" ++ s ++ ""
diff --git a/lib/Xmobar/Plugins/Screensaver.hs b/lib/Xmobar/Plugins/Screensaver.hs
index cdc1ce1..c591adb 100644
--- a/lib/Xmobar/Plugins/Screensaver.hs
+++ b/lib/Xmobar/Plugins/Screensaver.hs
@@ -2,14 +2,15 @@
module Xmobar.Plugins.Screensaver where
-import Control.Concurrent
-import Control.Monad
+import Control.Concurrent
+import Control.Monad
-import DBus.Screensaver
+import DBus.Screensaver
-import Xmobar
+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 = "" ++ s ++ ""
diff --git a/lib/Xmobar/Plugins/VPN.hs b/lib/Xmobar/Plugins/VPN.hs
index c518e32..e2837f9 100644
--- a/lib/Xmobar/Plugins/VPN.hs
+++ b/lib/Xmobar/Plugins/VPN.hs
@@ -3,10 +3,11 @@
module Xmobar.Plugins.VPN where
-import DBus
-import DBus.Client
+import DBus
+import DBus.Client
-import Xmobar
+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 = "" ++ s ++ ""
diff --git a/my-xmonad.cabal b/my-xmonad.cabal
index fd0efe7..e0e8465 100644
--- a/my-xmonad.cabal
+++ b/my-xmonad.cabal
@@ -15,6 +15,7 @@ library
, DBus.IntelBacklight
, DBus.Internal
, DBus.Screensaver
+ , Xmobar.Common
, Xmobar.Plugins.Bluetooth
, Xmobar.Plugins.IntelBacklight
, Xmobar.Plugins.Screensaver