Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:haasn
xmobar
xmobar-net-bits.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File xmobar-net-bits.patch of Package xmobar
From d57679afe9c8187f739f9f263a66a952dcb82083 Mon Sep 17 00:00:00 2001 From: Niklas Haas <git@haasn.dev> Date: Mon, 17 Oct 2022 17:36:35 +0200 Subject: [PATCH] net: switch to bits instead of bytes --- src/Xmobar/Plugins/Monitors/Net.hs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Xmobar/Plugins/Monitors/Net.hs b/src/Xmobar/Plugins/Monitors/Net.hs index 23b3dc3..f326953 100644 --- a/src/Xmobar/Plugins/Monitors/Net.hs +++ b/src/Xmobar/Plugins/Monitors/Net.hs @@ -75,10 +75,10 @@ data UnitPerSec = Bs | KBs | MBs | GBs deriving (Eq,Enum,Ord) data NetValue = NetValue Float UnitPerSec deriving (Eq,Show) instance Show UnitPerSec where - show Bs = "B/s" - show KBs = "KB/s" - show MBs = "MB/s" - show GBs = "GB/s" + show Bs = "b/s" + show KBs = "kb/s" + show MBs = "Mb/s" + show GBs = "Gb/s" netConfig :: IO MConfig netConfig = mkMConfig @@ -90,8 +90,8 @@ formatNet mipat d = do s <- getConfigValue useSuffix dd <- getConfigValue decDigits let str True v = showDigits dd d' ++ show u - where (NetValue d' u) = byteNetVal v - str False v = showDigits dd $ v / 1024 + where (NetValue d' u) = bitNetVal v + str False v = showDigits dd $ v / 1000 b <- showLogBar 0.9 d vb <- showLogVBar 0.9 d ipat <- showLogIconPattern mipat 0.9 d @@ -116,7 +116,7 @@ parseNet nref nd = do writeIORef nref (n1, t1) let scx = realToFrac (diffUTCTime t1 t0) scx' = if scx > 0 then scx else 1 - rate da db = takeDigits 2 $ fromIntegral (db - da) / scx' + rate da db = takeDigits 2 $ 8 * fromIntegral (db - da) / scx' diffRate (N d (ND ra ta)) (N _ (ND rb tb)) = N d (ND (rate ra rb) (rate ta tb)) diffRate (N d NI) _ = N d NI diffRate _ (N d NI) = N d NI @@ -163,9 +163,9 @@ startDynNet a r cb = do return (nref, d) runM a netConfig (runNets refs) r cb -byteNetVal :: Float -> NetValue -byteNetVal v - | v < 1024**1 = NetValue v Bs - | v < 1024**2 = NetValue (v/1024**1) KBs - | v < 1024**3 = NetValue (v/1024**2) MBs - | otherwise = NetValue (v/1024**3) GBs +bitNetVal :: Float -> NetValue +bitNetVal v + | v < 1000**1 = NetValue v Bs + | v < 1000**2 = NetValue (v/1000**1) KBs + | v < 1000**3 = NetValue (v/1000**2) MBs + | otherwise = NetValue (v/1000**3) GBs -- 2.37.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor