nixos-config/modules/workspace/i3blocks/scripts/free.hs

11 lines
315 B
Haskell
Raw Normal View History

2020-02-17 17:00:59 +04:00
import System.Exit
main :: IO ()
main = do
freeMemory <- read
<$> (!!1) <$> words
<$> (!!2) <$> lines
<$> readFile "/proc/meminfo"
putStrLn $ (take 5 $ show $ freeMemory / 1000000) ++ "GB"
exitWith $ if freeMemory > 500000 then ExitSuccess else ExitFailure 33