pakej-0.2.0.0: Status bar daemon

Safe HaskellNone
LanguageHaskell2010

Pakej.Widget.Memory

Contents

Description

A parser for /proc/meminfo

Synopsis

Memory metadata

data Mem Source

Abstract data type representing procmeminfo contents

Instances

type Query a = Mem -> Maybe a Source

Memory metadata query

widget :: Text -> Query Text -> PakejWidget Text Source

Construct a Text widget from the initial value and the memory metadata query

Make sense of memory metadata

ratio :: Fractional a => Query a -> Query a -> Query a Source

The ratio between the results of two memory metadata queries

total :: Num a => Query a Source

Total amount of memory installed on the machine

available :: Num a => Query a Source

Amount of memory available for consumption

Accurate result requires newer kernels. On older kernels it downgrades to approximate calculations

used :: Num a => Query a Source

Amount of memory already in use

Accurate result requires newer kernels. On older kernels it downgrades to approximate calculations

lookup :: Num a => Text -> Query a Source

Generic memory metadata lookup

Memory metadata parser

getData :: FilePath -> IO (Either Text Mem) Source

Parse /proc/meminfo (or any file with the same format) data to the key-value mapping, e.g. if

% cat /proc/meminfo
MemTotal:        3912112 kB
MemFree:          170128 kB

then

>>> getData "/proc/meminfo"
Right (fromList [("MemTotal", 3912112), ("MemFree", 170128), ...])

If any problems are encountered while parsing it returns the first one wrapped in Left

Catches I/O exceptions thrown upon opening and reading the file and presents their error message wrapped in Left