taffybar-0.4.5: A desktop bar similar to xmobar, but with more GUI

Safe Haskell | None
Language | Haskell2010

System.Information.Battery

Contents

- Types
- Accessors

Description

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.

Synopsis

- 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
  - = BatteryStateUnknown
  - | BatteryStateCharging
  - | BatteryStateDischarging
  - | BatteryStateEmpty
  - | BatteryStateFullyCharged
  - | BatteryStatePendingCharge
  - | BatteryStatePendingDischarge
- data BatteryTechnology
  - = BatteryTechnologyUnknown
  - | BatteryTechnologyLithiumIon
  - | BatteryTechnologyLithiumPolymer
  - | BatteryTechnologyLithiumIronPhosphate
  - | BatteryTechnologyLeadAcid
  - | BatteryTechnologyNickelCadmium
  - | BatteryTechnologyNickelMetalHydride
- data BatteryType
  - = BatteryTypeUnknown
  - | BatteryTypeLinePower
  - | BatteryTypeBatteryType
  - | BatteryTypeUps
  - | BatteryTypeMonitor
  - | BatteryTypeMouse
  - | BatteryTypeKeyboard
  - | BatteryTypePda
  - | BatteryTypePhone
- batteryContextNew :: IO (Maybe BatteryContext)
- getBatteryInfo :: BatteryContext -> IO (Maybe BatteryInfo)

# Types

data BatteryContext Source

An opaque wrapper around some internal library state

data BatteryInfo Source

There are a few fields supported by UPower that aren't exposed here.. could be easily.

Constructors

BatteryInfo |

Fields

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 Source

Constructors

BatteryStateUnknown |
BatteryStateCharging |
BatteryStateDischarging |
BatteryStateEmpty |
BatteryStateFullyCharged |
BatteryStatePendingCharge |
BatteryStatePendingDischarge |

Instances

Enum BatteryState Source |
Eq BatteryState Source |
Ord BatteryState Source |
Show BatteryState Source |

data BatteryTechnology Source

Constructors

BatteryTechnologyUnknown |
BatteryTechnologyLithiumIon |
BatteryTechnologyLithiumPolymer |
BatteryTechnologyLithiumIronPhosphate |
BatteryTechnologyLeadAcid |
BatteryTechnologyNickelCadmium |
BatteryTechnologyNickelMetalHydride |

Instances

Enum BatteryTechnology Source |
Eq BatteryTechnology Source |
Ord BatteryTechnology Source |
Show BatteryTechnology Source |

data BatteryType Source

Constructors

BatteryTypeUnknown |
BatteryTypeLinePower |
BatteryTypeBatteryType |
BatteryTypeUps |
BatteryTypeMonitor |
BatteryTypeMouse |
BatteryTypeKeyboard |
BatteryTypePda |
BatteryTypePhone |

Instances

Enum BatteryType Source |
Eq BatteryType Source |
Ord BatteryType Source |
Show BatteryType Source |

# Accessors

batteryContextNew :: IO (Maybe BatteryContext) Source

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 (Maybe BatteryInfo) Source

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.