diff options
author | jao <jao@gnu.org> | 2020-02-28 04:40:52 +0000 |
---|---|---|
committer | jao <jao@gnu.org> | 2020-03-05 17:55:12 +0000 |
commit | be9b21d52767e42de636716139b84285c29ff5ec (patch) | |
tree | 5646056a3b7c698920dc1531cca3c102e0694787 | |
parent | ae16735a74a711c0ed7adf6e1df18b75a5a26205 (diff) | |
download | xmobar-be9b21d52767e42de636716139b84285c29ff5ec.tar.gz xmobar-be9b21d52767e42de636716139b84285c29ff5ec.tar.bz2 |
Network: up indicator
-rw-r--r-- | readme.md | 9 | ||||
-rw-r--r-- | src/Xmobar/Plugins/Monitors/Net.hs | 9 |
2 files changed, 12 insertions, 6 deletions
@@ -798,11 +798,14 @@ specification, such as `("clear", "<icon=weather-clear.xbm/>")`. - Args: default monitor arguments, plus: - `--rx-icon-pattern`: dynamic string for reception rate in `rxipat`. - `--tx-icon-pattern`: dynamic string for transmission rate in `txipat`. + - `--up`: string used for the `up` variable value when the + interface is up. - Variables that can be used with the `-t`/`--template` argument: `dev`, `rx`, `tx`, `rxbar`, `rxvbar`, `rxipat`, `txbar`, `txvbar`, - `txipat`. Reception and transmission rates (`rx` and `tx`) are displayed - by default as Kb/s, without any suffixes, but you can set the `-S` to - "True" to make them displayed with adaptive units (Kb/s, Mb/s, etc.). + `txipat`, `up`. Reception and transmission rates (`rx` and `tx`) are + displayed by default as Kb/s, without any suffixes, but you can set + the `-S` to "True" to make them displayed with adaptive units (Kb/s, + Mb/s, etc.). - Default template: `<dev>: <rx>KB|<tx>KB` ### `DynNetwork Args RefreshRate` diff --git a/src/Xmobar/Plugins/Monitors/Net.hs b/src/Xmobar/Plugins/Monitors/Net.hs index db11724..97deacd 100644 --- a/src/Xmobar/Plugins/Monitors/Net.hs +++ b/src/Xmobar/Plugins/Monitors/Net.hs @@ -1,7 +1,7 @@ ----------------------------------------------------------------------------- -- | -- Module : Plugins.Monitors.Net --- Copyright : (c) 2011, 2012, 2013, 2014, 2017 Jose Antonio Ortega Ruiz +-- Copyright : (c) 2011, 2012, 2013, 2014, 2017, 2020 Jose Antonio Ortega Ruiz -- (c) 2007-2010 Andrea Rossato -- License : BSD-style (see LICENSE) -- @@ -49,6 +49,7 @@ data NetOpts = NetOpts { rxIconPattern :: Maybe IconPattern , txIconPattern :: Maybe IconPattern , onlyDevList :: Maybe DevList + , upIndicator :: String } defaultOpts :: NetOpts @@ -56,6 +57,7 @@ defaultOpts = NetOpts { rxIconPattern = Nothing , txIconPattern = Nothing , onlyDevList = Nothing + , upIndicator = "+" } options :: [OptDescr (NetOpts -> NetOpts)] @@ -64,6 +66,7 @@ options = o { rxIconPattern = Just $ parseIconPattern x }) "") "" , Option "" ["tx-icon-pattern"] (ReqArg (\x o -> o { txIconPattern = Just $ parseIconPattern x }) "") "" + , Option "" ["up"] (ReqArg (\x o -> o { upIndicator = x }) "") "" , Option "" ["devices"] (ReqArg (\x o -> o { onlyDevList = Just $ parseDevList x }) "") "" ] @@ -103,7 +106,7 @@ instance Ord num => Ord (NetDevInfo num) where netConfig :: IO MConfig netConfig = mkMConfig "<dev>: <rx>KB|<tx>KB" -- template - ["dev", "rx", "tx", "rxbar", "rxvbar", "rxipat", "txbar", "txvbar", "txipat"] -- available replacements + ["dev", "rx", "tx", "rxbar", "rxvbar", "rxipat", "txbar", "txvbar", "txipat", "up"] -- available replacements operstateDir :: String -> FilePath operstateDir d = "/sys/class/net" </> d </> "operstate" @@ -160,7 +163,7 @@ printNet opts nd = N d (ND r t) -> do (rx, rb, rvb, ripat) <- formatNet (rxIconPattern opts) r (tx, tb, tvb, tipat) <- formatNet (txIconPattern opts) t - parseTemplate [d,rx,tx,rb,rvb,ripat,tb,tvb,tipat] + parseTemplate [d,rx,tx,rb,rvb,ripat,tb,tvb,tipat, upIndicator opts] N _ NI -> return "" NA -> getConfigValue naString |