This is a simple library to query the Linux UPower daemon (via DBus) for battery information. Currently, it only retrieves information for the first battery it finds.
- data BatteryContext
- data BatteryInfo = BatteryInfo {
- batteryNativePath :: Text
- batteryVendor :: Text
- batteryModel :: Text
- batterySerial :: Text
- batteryType :: BatteryType
- batteryPowerSupply :: Bool
- batteryHasHistory :: Bool
- batteryHasStatistics :: Bool
- batteryOnline :: Bool
- batteryEnergy :: Double
- batteryEnergyEmpty :: Double
- batteryEnergyFull :: Double
- batteryEnergyFullDesign :: Double
- batteryEnergyRate :: Double
- batteryVoltage :: Double
- batteryTimeToEmpty :: Int64
- batteryTimeToFull :: Int64
- batteryPercentage :: Double
- batteryIsPresent :: Bool
- batteryState :: BatteryState
- batteryIsRechargable :: Bool
- batteryCapacity :: Double
- batteryTechnology :: BatteryTechnology
- data BatteryState
- data BatteryTechnology
- data BatteryType
- batteryContextNew :: IO (Maybe BatteryContext)
- getBatteryInfo :: BatteryContext -> IO BatteryInfo
Types
data BatteryContext
An opaque wrapper around some internal library state
data BatteryInfo
There are a few fields supported by UPower that aren't exposed here.. could be easily.
BatteryInfo | |
|
data BatteryState
data BatteryTechnology
data BatteryType
Accessors
batteryContextNew :: IO (Maybe BatteryContext)
Construct a battery context if possible. This could fail if the
UPower daemon is not running. The context can be used to get
actual battery state with getBatteryInfo
.
getBatteryInfo :: BatteryContext -> IO BatteryInfo
Query the UPower daemon about information on a specific battery. If some fields are not actually present, they may have bogus values here. Don't bet anything critical on it.