Skip to content

Instantly share code, notes, and snippets.

View CRTified's full-sized avatar
🤔

Carl Richard Theodor Schneider CRTified

🤔
View GitHub Profile
#################
# CORE SETTINGS #
#################
#
# Zim settings
#
@CRTified
CRTified / acpi_power_snippet.hs
Created April 19, 2017 22:43
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 ++ "/"