Skip to content

Instantly share code, notes, and snippets.

@CRTified
Created April 19, 2017 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CRTified/ae2480e23f828577b3794ccfc52e8c21 to your computer and use it in GitHub Desktop.
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
-- 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