summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar/Plugins/Monitors/Uptime.hs
diff options
context:
space:
mode:
authorMichal Zielonka <michal.zielonka.8001@gmail.com>2021-10-08 14:42:51 +0200
committerMichal Zielonka <michal.zielonka.8001@gmail.com>2021-10-08 15:44:01 +0200
commit3d469771a549062be70f4e316680dac00a68d1d2 (patch)
tree8e0683da0f40d74fd224873e4df062db30fc41f5 /src/Xmobar/Plugins/Monitors/Uptime.hs
parentb99a8a6833a1b38882b463fd72784cd6d6f91d9e (diff)
downloadxmobar-3d469771a549062be70f4e316680dac00a68d1d2.tar.gz
xmobar-3d469771a549062be70f4e316680dac00a68d1d2.tar.bz2
try to add build action for freebsd + uptime plugin split
Diffstat (limited to 'src/Xmobar/Plugins/Monitors/Uptime.hs')
-rw-r--r--src/Xmobar/Plugins/Monitors/Uptime.hs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/Xmobar/Plugins/Monitors/Uptime.hs b/src/Xmobar/Plugins/Monitors/Uptime.hs
index 235fc85..646edc8 100644
--- a/src/Xmobar/Plugins/Monitors/Uptime.hs
+++ b/src/Xmobar/Plugins/Monitors/Uptime.hs
@@ -1,3 +1,5 @@
+{-#LANGUAGE CPP #-}
+
------------------------------------------------------------------------------
-- |
-- Module : Plugins.Monitors.Uptime
@@ -19,22 +21,22 @@ module Xmobar.Plugins.Monitors.Uptime (uptimeConfig, runUptime) where
import Xmobar.Plugins.Monitors.Common
-import qualified Data.ByteString.Lazy.Char8 as B
+#if defined(freebsd_HOST_OS)
+import qualified Xmobar.Plugins.Monitors.Uptime.FreeBSD as MU
+#else
+import qualified Xmobar.Plugins.Monitors.Uptime.Linux as MU
+#endif
uptimeConfig :: IO MConfig
uptimeConfig = mkMConfig "Up <days>d <hours>h <minutes>m"
["days", "hours", "minutes", "seconds"]
-readUptime :: IO Float
-readUptime =
- fmap (read . B.unpack . head . B.words) (B.readFile "/proc/uptime")
-
secsPerDay :: Integer
secsPerDay = 24 * 3600
uptime :: Monitor [String]
uptime = do
- t <- io readUptime
+ t <- io MU.readUptime
u <- getConfigValue useSuffix
let tsecs = floor t
secs = tsecs `mod` secsPerDay