taffybar-0.4.6: 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 # |

Methods

succ :: BatteryState -> BatteryState #

pred :: BatteryState -> BatteryState #

toEnum :: Int -> BatteryState #

fromEnum :: BatteryState -> Int #

enumFrom :: BatteryState -> [BatteryState] #

enumFromThen :: BatteryState -> BatteryState -> [BatteryState] #

enumFromTo :: BatteryState -> BatteryState -> [BatteryState] #

enumFromThenTo :: BatteryState -> BatteryState -> BatteryState -> [BatteryState] #

Eq BatteryState Source # |
Methods (==) :: BatteryState -> BatteryState -> Bool # (/=) :: BatteryState -> BatteryState -> Bool #
Ord BatteryState Source # |
Methods compare :: BatteryState -> BatteryState -> Ordering # (<) :: BatteryState -> BatteryState -> Bool # (<=) :: BatteryState -> BatteryState -> Bool # (>) :: BatteryState -> BatteryState -> Bool # (>=) :: BatteryState -> BatteryState -> Bool # max :: BatteryState -> BatteryState -> BatteryState # min :: BatteryState -> BatteryState -> BatteryState #
Show BatteryState Source # |
Methods showsPrec :: Int -> BatteryState -> ShowS # show :: BatteryState -> String # showList :: [BatteryState] -> ShowS #

data BatteryTechnology Source #

Constructors

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

Instances

Enum BatteryTechnology Source # |

Methods

succ :: BatteryTechnology -> BatteryTechnology #

pred :: BatteryTechnology -> BatteryTechnology #

toEnum :: Int -> BatteryTechnology #

fromEnum :: BatteryTechnology -> Int #

enumFrom :: BatteryTechnology -> [BatteryTechnology] #

enumFromThen :: BatteryTechnology -> BatteryTechnology -> [BatteryTechnology] #

enumFromTo :: BatteryTechnology -> BatteryTechnology -> [BatteryTechnology] #

enumFromThenTo :: BatteryTechnology -> BatteryTechnology -> BatteryTechnology -> [BatteryTechnology] #

Eq BatteryTechnology Source # |
Methods (==) :: BatteryTechnology -> BatteryTechnology -> Bool # (/=) :: BatteryTechnology -> BatteryTechnology -> Bool #
Ord BatteryTechnology Source # |

Methods

compare :: BatteryTechnology -> BatteryTechnology -> Ordering #

(<) :: BatteryTechnology -> BatteryTechnology -> Bool #

(<=) :: BatteryTechnology -> BatteryTechnology -> Bool #

(>) :: BatteryTechnology -> BatteryTechnology -> Bool #

(>=) :: BatteryTechnology -> BatteryTechnology -> Bool #

max :: BatteryTechnology -> BatteryTechnology -> BatteryTechnology #

min :: BatteryTechnology -> BatteryTechnology -> BatteryTechnology #

Show BatteryTechnology Source # |
Methods showsPrec :: Int -> BatteryTechnology -> ShowS # show :: BatteryTechnology -> String # showList :: [BatteryTechnology] -> ShowS #

data BatteryType Source #

Constructors

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

Instances

Enum BatteryType Source # |
Methods succ :: BatteryType -> BatteryType # pred :: BatteryType -> BatteryType # toEnum :: Int -> BatteryType # fromEnum :: BatteryType -> Int # enumFrom :: BatteryType -> [BatteryType] # enumFromThen :: BatteryType -> BatteryType -> [BatteryType] # enumFromTo :: BatteryType -> BatteryType -> [BatteryType] # enumFromThenTo :: BatteryType -> BatteryType -> BatteryType -> [BatteryType] #
Eq BatteryType Source # |
Methods (==) :: BatteryType -> BatteryType -> Bool # (/=) :: BatteryType -> BatteryType -> Bool #
Ord BatteryType Source # |
Methods compare :: BatteryType -> BatteryType -> Ordering # (<) :: BatteryType -> BatteryType -> Bool # (<=) :: BatteryType -> BatteryType -> Bool # (>) :: BatteryType -> BatteryType -> Bool # (>=) :: BatteryType -> BatteryType -> Bool # max :: BatteryType -> BatteryType -> BatteryType # min :: BatteryType -> BatteryType -> BatteryType #
Show BatteryType Source # |
Methods showsPrec :: Int -> BatteryType -> ShowS # show :: BatteryType -> String # showList :: [BatteryType] -> ShowS #

# 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.