summaryrefslogtreecommitdiffhomepage
path: root/src/Plugins/Monitors/MultiCpu.hs
diff options
context:
space:
mode:
authorbobtwinkles <srkoser+GitHub@gmail.com>2018-03-17 19:00:10 -0400
committerbobtwinkles <srkoser+GitHub@gmail.com>2018-03-17 19:00:10 -0400
commitcb38935826d4edf1e75594fd554ff690f820c6d4 (patch)
treefd1b646eb211fd9df1b0dfeb844fffff99f8d859 /src/Plugins/Monitors/MultiCpu.hs
parentbcd8cef356be623f32ea1e0f79bca1f8986fdee7 (diff)
downloadxmobar-cb38935826d4edf1e75594fd554ff690f820c6d4.tar.gz
xmobar-cb38935826d4edf1e75594fd554ff690f820c6d4.tar.bz2
Add fallback icon support to MultiCpu
To make the <autoipat> pattern truly automatic, there needs to be a fallback icon set to use when the user hasn't specified enough --load-icon-patterns. This adds the fallback under the name --fallback-icon-pattern
Diffstat (limited to 'src/Plugins/Monitors/MultiCpu.hs')
-rw-r--r--src/Plugins/Monitors/MultiCpu.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Plugins/Monitors/MultiCpu.hs b/src/Plugins/Monitors/MultiCpu.hs
index b290690..1477cf6 100644
--- a/src/Plugins/Monitors/MultiCpu.hs
+++ b/src/Plugins/Monitors/MultiCpu.hs
@@ -24,12 +24,14 @@ import System.Console.GetOpt
data MultiCpuOpts = MultiCpuOpts
{ loadIconPatterns :: [IconPattern]
, loadIconPattern :: Maybe IconPattern
+ , fallbackIconPattern :: Maybe IconPattern
}
defaultOpts :: MultiCpuOpts
defaultOpts = MultiCpuOpts
{ loadIconPatterns = []
, loadIconPattern = Nothing
+ , fallbackIconPattern = Nothing
}
options :: [OptDescr (MultiCpuOpts -> MultiCpuOpts)]
@@ -38,6 +40,8 @@ options =
o { loadIconPattern = Just $ parseIconPattern x }) "") ""
, Option "" ["load-icon-patterns"] (ReqArg (\x o ->
o { loadIconPatterns = parseIconPattern x : loadIconPatterns o }) "") ""
+ , Option "" ["fallback-icon-pattern"] (ReqArg (\x o ->
+ o { fallbackIconPattern = Just $ parseIconPattern x }) "") ""
]
parseOpts :: [String] -> IO MultiCpuOpts
@@ -97,7 +101,7 @@ formatCpu opts i xs
where tryString
| i == 0 = loadIconPattern opts
| i <= length (loadIconPatterns opts) = Just $ loadIconPatterns opts !! (i - 1)
- | otherwise = Nothing
+ | otherwise = fallbackIconPattern opts
splitEvery :: Int -> [a] -> [[a]]
splitEvery n = unfoldr (\x -> if null x then Nothing else Just $ splitAt n x)