summaryrefslogtreecommitdiffhomepage
path: root/Plugins/Uptime.hs
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2010-12-12 23:51:14 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2010-12-12 23:51:14 +0100
commitefd9bc7177c66d7bb9a994e919d915ecb5c75154 (patch)
tree8acc67d927ff801004e45a4b297b35a0953550a4 /Plugins/Uptime.hs
parent52be04baa703cb5c0263aecb61f0079230367cd0 (diff)
downloadxmobar-efd9bc7177c66d7bb9a994e919d915ecb5c75154.tar.gz
xmobar-efd9bc7177c66d7bb9a994e919d915ecb5c75154.tar.bz2
Uptime as a Monitor
Diffstat (limited to 'Plugins/Uptime.hs')
-rw-r--r--Plugins/Uptime.hs51
1 files changed, 0 insertions, 51 deletions
diff --git a/Plugins/Uptime.hs b/Plugins/Uptime.hs
deleted file mode 100644
index 6d81acd..0000000
--- a/Plugins/Uptime.hs
+++ /dev/null
@@ -1,51 +0,0 @@
-------------------------------------------------------------------------------
--- |
--- Module : Plugins.Uptime
--- Copyright : (c) 2010 Jose Antonio Ortega Ruiz
--- License : BSD3-style (see LICENSE)
---
--- Maintainer : jao@gnu.org
--- Stability : unstable
--- Portability : unportable
--- Created: Sun Dec 12, 2010 20:26
---
---
--- Uptime
---
-------------------------------------------------------------------------------
-
-
-module Plugins.Uptime (Uptime(..)) where
-
-import Plugins
-
-import qualified Data.ByteString.Lazy.Char8 as B
-
-data Uptime = Uptime String Int
- deriving (Read, Show)
-
-instance Exec Uptime where
- alias (Uptime a _) = a
- run (Uptime _ _) = uptime
- rate (Uptime _ r) = r
-
-readUptime :: IO Float
-readUptime =
- fmap (read . B.unpack . head . B.words) (B.readFile "/proc/uptime")
-
-secsPerDay :: Integer
-secsPerDay = 24 * 3600
-
-uptime :: IO String
-uptime = do
- t <- readUptime
- let tsecs = floor t
- secs = tsecs `mod` secsPerDay
- days = tsecs `quot` secsPerDay
- hrs = secs `quot` 3600
- mins = (secs `mod` 3600) `div` 60
- dstr | days == 0 = ""
- | otherwise = show days ++ "d "
- str x | x < 10 = '0':show x
- | otherwise = show x
- return $ dstr ++ str hrs ++ ":" ++ str mins