From b89668884f021e1023160febb680a43588a6aeaa Mon Sep 17 00:00:00 2001 From: jao Date: Fri, 15 Dec 2017 03:32:27 +0100 Subject: Configurable WM_CLASS and WM_NAME (should address #323) --- news.md | 11 +++++++++++ readme.md | 9 +++++++++ src/Config.hs | 4 ++++ src/Main.hs | 6 ++++++ src/Parsers.hs | 8 ++++++-- src/Window.hs | 4 ++-- 6 files changed, 38 insertions(+), 4 deletions(-) diff --git a/news.md b/news.md index c5d4220..6de6dcf 100644 --- a/news.md +++ b/news.md @@ -1,5 +1,16 @@ % xmobar - Release notes +## Version 0.25 + +_New features_ + + - The X11 properties `WM_NAME` and `WM_CLASS` for xmobar windows can + be setup in either the configuration file (`wmName` and `wmClass`) + or using the new flags `-n` adn `-w` (see [issue #323]). + +[issue #303]: https://github.com/jaor/xmobar/issues/323 + + ## Version 0.24.5 (May, 2017) _Bug fixes_ diff --git a/readme.md b/readme.md index 359ca17..bb8159c 100644 --- a/readme.md +++ b/readme.md @@ -367,6 +367,13 @@ Other configuration options: `template` : The output template. + +`wmClass` +: The value for the window's X11 WM_CLASS property. Defaults to "xmobar". + +`wmName` +: The value for the window's X11 WM_NAME property. Defaults to "xmobar". + ### Running xmobar with i3status xmobar can be used to display information generated by [i3status], a @@ -394,6 +401,8 @@ xmobar --help): -h, -? --help This help -V --version Show version information -f font name --font=font name The font name + -w class --wmclass=class X11 WM_CLASS property + -n name --wmname=name X11 WM_NAME property -B bg color --bgcolor=bg color The background color. Default black -F fg color --fgcolor=fg color The foreground color. Default grey -A alpha --alpha=alpha The transparency: 0 is transparent, 255 (the default) is opaque 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" -- cgit v1.2.3