Created
April 19, 2017 22:43
-
-
Save CRTified/ae2480e23f828577b3794ccfc52e8c21 to your computer and use it in GitHub Desktop.
Small snippet for a xmonad acpi logger that does not depend on /usr/bin/acpi or sed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- dev is the device that shall be read (Like "BAT0") | |
-- attr are the attributes that are going to be read ("status" for charging status, "capacity" for charged capacity, and so on) | |
acpi_power :: String -> [String] -> Logger | |
acpi_power dev attr = io $ do | |
attrOut <- mapM (\x -> liftIO $ readFile $ sysFsPath ++ x) attr | |
return $ Just $ filter (/= '\n') (intercalate " " attrOut) | |
where | |
sysFsPath = "/sys/class/power_supply/" ++ dev ++ "/" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment