summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2017-12-15 03:32:27 +0100
committerjao <jao@gnu.org>2017-12-15 03:32:27 +0100
commitb89668884f021e1023160febb680a43588a6aeaa (patch)
treeec625019888664efb6c7502b754269daebab16db /src
parenta7bc612666062b5c48efae74054a453334727e91 (diff)
downloadxmobar-b89668884f021e1023160febb680a43588a6aeaa.tar.gz
xmobar-b89668884f021e1023160febb680a43588a6aeaa.tar.bz2
Configurable WM_CLASS and WM_NAME (should address #323)
Diffstat (limited to 'src')
-rw-r--r--src/Config.hs4
-rw-r--r--src/Main.hs6
-rw-r--r--src/Parsers.hs8
-rw-r--r--src/Window.hs4
4 files changed, 18 insertions, 4 deletions
diff --git a/src/Config.hs b/src/Config.hs
index 59d6bd4..b131648 100644
--- a/src/Config.hs
+++ b/src/Config.hs
@@ -50,6 +50,8 @@ import Plugins.DateZone
data Config =
Config { font :: String -- ^ Font
, additionalFonts :: [String] -- ^ List of alternative fonts
+ , wmClass :: String -- ^ X11 WM_CLASS property value
+ , wmName :: String -- ^ X11 WM_NAME property value
, bgColor :: String -- ^ Backgroud color
, fgColor :: String -- ^ Default font color
, position :: XPosition -- ^ Top Bottom or Static
@@ -112,6 +114,8 @@ defaultConfig :: Config
defaultConfig =
Config { font = "-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*"
, additionalFonts = []
+ , wmClass = "xmobar"
+ , wmName = "xmobar"
, bgColor = "#000000"
, fgColor = "#BFBFBF"
, alpha = 255
diff --git a/src/Main.hs b/src/Main.hs
index 3760353..0c96688 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -135,6 +135,8 @@ data Opts = Help
| OnScr String
| IconRoot String
| Position String
+ | WmClass String
+ | WmName String
deriving Show
options :: [OptDescr Opts]
@@ -142,6 +144,8 @@ options =
[ Option "h?" ["help"] (NoArg Help) "This help"
, Option "V" ["version"] (NoArg Version) "Show version information"
, Option "f" ["font"] (ReqArg Font "font name") "The font name"
+ , Option "w" ["wmclass"] (ReqArg WmClass "class") "X11 WM_CLASS property"
+ , Option "n" ["wmname"] (ReqArg WmName "name") "X11 WM_NAME property"
, Option "B" ["bgcolor"] (ReqArg BgColor "bg color" )
"The background color. Default black"
, Option "F" ["fgcolor"] (ReqArg FgColor "fg color")
@@ -206,6 +210,8 @@ doOpts conf (o:oo) =
Help -> putStr usage >> exitSuccess
Version -> putStrLn info >> exitSuccess
Font s -> doOpts' (conf {font = s})
+ WmClass s -> doOpts' (conf {wmClass = s})
+ WmName s -> doOpts' (conf {wmName = s})
BgColor s -> doOpts' (conf {bgColor = s})
FgColor s -> doOpts' (conf {fgColor = s})
Alpha n -> doOpts' (conf {alpha = read n})
diff --git a/src/Parsers.hs b/src/Parsers.hs
index 5f5949c..bab13cb 100644
--- a/src/Parsers.hs
+++ b/src/Parsers.hs
@@ -212,7 +212,8 @@ parseConfig = runParser parseConf fields "Config" . stripComments
return (x,s)
perms = permute $ Config
- <$?> pFont <|?> pFontList <|?> pBgColor <|?> pFgColor
+ <$?> pFont <|?> pFontList <|?> pWmClass <|?> pWmName
+ <|?> pBgColor <|?> pFgColor
<|?> pPosition <|?> pTextOffset <|?> pIconOffset <|?> pBorder
<|?> pBdColor <|?> pBdWidth <|?> pAlpha <|?> pHideOnStart
<|?> pAllDesktops <|?> pOverrideRedirect <|?> pPickBroadest
@@ -220,7 +221,8 @@ parseConfig = runParser parseConf fields "Config" . stripComments
<|?> pCommands <|?> pSepChar <|?> pAlignSep <|?> pTemplate
- fields = [ "font", "additionalFonts","bgColor", "fgColor", "sepChar"
+ fields = [ "font", "additionalFonts","bgColor", "fgColor"
+ , "wmClass", "wmName", "sepChar"
, "alignSep" , "border", "borderColor" ,"template"
, "position" , "textOffset", "iconOffset"
, "allDesktops", "overrideRedirect", "pickBroadest"
@@ -230,6 +232,8 @@ parseConfig = runParser parseConf fields "Config" . stripComments
pFont = strField font "font"
pFontList = strListField additionalFonts "additionalFonts"
+ pWmClass = strField wmClass "wmclass"
+ pWmName = strField wmName "windowName"
pBgColor = strField bgColor "bgColor"
pFgColor = strField fgColor "fgColor"
pBdColor = strField borderColor "borderColor"
diff --git a/src/Window.hs b/src/Window.hs
index 11ea82e..d2506db 100644
--- a/src/Window.hs
+++ b/src/Window.hs
@@ -100,8 +100,8 @@ setProperties c d w = do
card <- mkatom "CARDINAL"
atom <- mkatom "ATOM"
- setTextProperty d w "xmobar" wM_CLASS
- setTextProperty d w "xmobar" wM_NAME
+ setTextProperty d w (wmClass c) wM_CLASS
+ setTextProperty d w (wmName c) wM_NAME
wtype <- mkatom "_NET_WM_WINDOW_TYPE"
dock <- mkatom "_NET_WM_WINDOW_TYPE_DOCK"