summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar/Plugins
diff options
context:
space:
mode:
authorMichaƂ Zielonka <michal.zielonka.8001@gmail.com>2021-10-19 23:53:30 +0200
committerGitHub <noreply@github.com>2021-10-19 22:53:30 +0100
commit92e93189528bcf583344dad81720abba935d5056 (patch)
tree6b3f1ddaeeb909a243fa128414882cde65a48590 /src/Xmobar/Plugins
parentbb3feb7aca468a5542e8686c747dcdc95be3dcde (diff)
downloadxmobar-92e93189528bcf583344dad81720abba935d5056.tar.gz
xmobar-92e93189528bcf583344dad81720abba935d5056.tar.bz2
add cirrus freebsd test (#580)
For start cirrus please use: https://cirrus-ci.org/guide/quick-start/ choose public repositories plan and add only xmobar as observed by cirrus. Also here is addes small fix for dividing by zero when cpu usage is calculated
Diffstat (limited to 'src/Xmobar/Plugins')
-rw-r--r--src/Xmobar/Plugins/Monitors/Cpu/FreeBSD.hs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/Xmobar/Plugins/Monitors/Cpu/FreeBSD.hs b/src/Xmobar/Plugins/Monitors/Cpu/FreeBSD.hs
index 7cb711a..7c80e55 100644
--- a/src/Xmobar/Plugins/Monitors/Cpu/FreeBSD.hs
+++ b/src/Xmobar/Plugins/Monitors/Cpu/FreeBSD.hs
@@ -39,11 +39,16 @@ parseCpu cref = do
intr = diff !! 3
idle = diff !! 4
total = user + nice + system + intr + idle
+ cpuUserPerc = if total > 0 then user/total else 0
+ cpuNicePerc = if total > 0 then nice/total else 0
+ cpuSystemPerc = if total > 0 then (system+intr)/total else 0
+ cpuIdlePerc = if total > 0 then idle/total else 0
+
return CpuData
- { cpuUser = user/total
- , cpuNice = nice/total
- , cpuSystem = (system+intr)/total
- , cpuIdle = idle/total
+ { cpuUser = cpuUserPerc
+ , cpuNice = cpuNicePerc
+ , cpuSystem = cpuSystemPerc
+ , cpuIdle = cpuIdlePerc
, cpuIowait = 0
- , cpuTotal = user/total
+ , cpuTotal = cpuUserPerc+cpuSystemPerc
}