Code from other project because I'm lazy
This commit is contained in:
parent
947bdaf0a5
commit
20304248aa
19
app/Main.hs
19
app/Main.hs
|
@ -1,4 +1,19 @@
|
|||
module Main where
|
||||
batteryCapacityFile = "/sys/class/power_supply/BAT0/capacity" :: FilePath
|
||||
batteryStatusFile = "/sys/class/power_supply/BAT0/status" :: FilePath
|
||||
|
||||
main :: IO ()
|
||||
main = putStrLn "Hello, Haskell!"
|
||||
main = do
|
||||
batteryCapacity <- readFile batteryCapacityFile
|
||||
batteryStatus <- readFile batteryStatusFile
|
||||
putStrLn $ formatInfo batteryStatus batteryCapacity
|
||||
|
||||
formatInfo :: String -> String -> String
|
||||
formatInfo status capacity = icon ++ " " ++ init capacity ++ "%"
|
||||
where icon
|
||||
| init status == "Full" = "🙂"
|
||||
| init status == "Charging" = "🔋"
|
||||
| init status == "Not charging" = "♻"
|
||||
| init status == "Unknown" = "Unknown"
|
||||
| read capacity <= 20 = "🪫"
|
||||
| read capacity <= 100 = "🙃"
|
||||
| otherwise = "Silly"
|
||||
|
|
Loading…
Reference in a new issue