{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE OverloadedStrings #-}
module System.Taffybar.DBus.Client.Params where

import DBus
import DBus.Generation
import Language.Haskell.TH
import System.Taffybar.DBus.Client.Util

playerGenerationParams :: GenerationParams
playerGenerationParams :: GenerationParams
playerGenerationParams = GenerationParams
defaultGenerationParams
  { genTakeSignalErrorHandler :: Bool
genTakeSignalErrorHandler = Bool
True
  , genObjectPath :: Maybe ObjectPath
genObjectPath = ObjectPath -> Maybe ObjectPath
forall a. a -> Maybe a
Just ObjectPath
"/org/mpris/MediaPlayer2"
  }


-- | The base object path for the UPower interface
uPowerBaseObjectPath :: ObjectPath
uPowerBaseObjectPath :: ObjectPath
uPowerBaseObjectPath = ObjectPath
"/org/freedesktop/UPower"

-- | The name of the power daemon bus
uPowerBusName :: BusName
uPowerBusName :: BusName
uPowerBusName = BusName
"org.freedesktop.UPower"

uPowerDeviceInterfaceName :: InterfaceName
uPowerDeviceInterfaceName :: InterfaceName
uPowerDeviceInterfaceName = InterfaceName
"org.freedesktop.UPower.Device"

uPowerGenerationParams :: GenerationParams
uPowerGenerationParams :: GenerationParams
uPowerGenerationParams = GenerationParams
defaultGenerationParams
  { genTakeSignalErrorHandler :: Bool
genTakeSignalErrorHandler = Bool
True
  , genBusName :: Maybe BusName
genBusName = BusName -> Maybe BusName
forall a. a -> Maybe a
Just BusName
uPowerBusName
  }

data BatteryType
  = BatteryTypeUnknown
  | BatteryTypeLinePower
  | BatteryTypeBatteryType
  | BatteryTypeUps
  | BatteryTypeMonitor
  | BatteryTypeMouse
  | BatteryTypeKeyboard
  | BatteryTypePda
  | BatteryTypePhone
  deriving (Int -> BatteryType -> ShowS
[BatteryType] -> ShowS
BatteryType -> String
(Int -> BatteryType -> ShowS)
-> (BatteryType -> String)
-> ([BatteryType] -> ShowS)
-> Show BatteryType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BatteryType -> ShowS
showsPrec :: Int -> BatteryType -> ShowS
$cshow :: BatteryType -> String
show :: BatteryType -> String
$cshowList :: [BatteryType] -> ShowS
showList :: [BatteryType] -> ShowS
Show, Eq BatteryType
Eq BatteryType
-> (BatteryType -> BatteryType -> Ordering)
-> (BatteryType -> BatteryType -> Bool)
-> (BatteryType -> BatteryType -> Bool)
-> (BatteryType -> BatteryType -> Bool)
-> (BatteryType -> BatteryType -> Bool)
-> (BatteryType -> BatteryType -> BatteryType)
-> (BatteryType -> BatteryType -> BatteryType)
-> Ord BatteryType
BatteryType -> BatteryType -> Bool
BatteryType -> BatteryType -> Ordering
BatteryType -> BatteryType -> BatteryType
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: BatteryType -> BatteryType -> Ordering
compare :: BatteryType -> BatteryType -> Ordering
$c< :: BatteryType -> BatteryType -> Bool
< :: BatteryType -> BatteryType -> Bool
$c<= :: BatteryType -> BatteryType -> Bool
<= :: BatteryType -> BatteryType -> Bool
$c> :: BatteryType -> BatteryType -> Bool
> :: BatteryType -> BatteryType -> Bool
$c>= :: BatteryType -> BatteryType -> Bool
>= :: BatteryType -> BatteryType -> Bool
$cmax :: BatteryType -> BatteryType -> BatteryType
max :: BatteryType -> BatteryType -> BatteryType
$cmin :: BatteryType -> BatteryType -> BatteryType
min :: BatteryType -> BatteryType -> BatteryType
Ord, BatteryType -> BatteryType -> Bool
(BatteryType -> BatteryType -> Bool)
-> (BatteryType -> BatteryType -> Bool) -> Eq BatteryType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BatteryType -> BatteryType -> Bool
== :: BatteryType -> BatteryType -> Bool
$c/= :: BatteryType -> BatteryType -> Bool
/= :: BatteryType -> BatteryType -> Bool
Eq, Int -> BatteryType
BatteryType -> Int
BatteryType -> [BatteryType]
BatteryType -> BatteryType
BatteryType -> BatteryType -> [BatteryType]
BatteryType -> BatteryType -> BatteryType -> [BatteryType]
(BatteryType -> BatteryType)
-> (BatteryType -> BatteryType)
-> (Int -> BatteryType)
-> (BatteryType -> Int)
-> (BatteryType -> [BatteryType])
-> (BatteryType -> BatteryType -> [BatteryType])
-> (BatteryType -> BatteryType -> [BatteryType])
-> (BatteryType -> BatteryType -> BatteryType -> [BatteryType])
-> Enum BatteryType
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: BatteryType -> BatteryType
succ :: BatteryType -> BatteryType
$cpred :: BatteryType -> BatteryType
pred :: BatteryType -> BatteryType
$ctoEnum :: Int -> BatteryType
toEnum :: Int -> BatteryType
$cfromEnum :: BatteryType -> Int
fromEnum :: BatteryType -> Int
$cenumFrom :: BatteryType -> [BatteryType]
enumFrom :: BatteryType -> [BatteryType]
$cenumFromThen :: BatteryType -> BatteryType -> [BatteryType]
enumFromThen :: BatteryType -> BatteryType -> [BatteryType]
$cenumFromTo :: BatteryType -> BatteryType -> [BatteryType]
enumFromTo :: BatteryType -> BatteryType -> [BatteryType]
$cenumFromThenTo :: BatteryType -> BatteryType -> BatteryType -> [BatteryType]
enumFromThenTo :: BatteryType -> BatteryType -> BatteryType -> [BatteryType]
Enum)

data BatteryState
  = BatteryStateUnknown
  | BatteryStateCharging
  | BatteryStateDischarging
  | BatteryStateEmpty
  | BatteryStateFullyCharged
  | BatteryStatePendingCharge
  | BatteryStatePendingDischarge
  deriving (Int -> BatteryState -> ShowS
[BatteryState] -> ShowS
BatteryState -> String
(Int -> BatteryState -> ShowS)
-> (BatteryState -> String)
-> ([BatteryState] -> ShowS)
-> Show BatteryState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BatteryState -> ShowS
showsPrec :: Int -> BatteryState -> ShowS
$cshow :: BatteryState -> String
show :: BatteryState -> String
$cshowList :: [BatteryState] -> ShowS
showList :: [BatteryState] -> ShowS
Show, Eq BatteryState
Eq BatteryState
-> (BatteryState -> BatteryState -> Ordering)
-> (BatteryState -> BatteryState -> Bool)
-> (BatteryState -> BatteryState -> Bool)
-> (BatteryState -> BatteryState -> Bool)
-> (BatteryState -> BatteryState -> Bool)
-> (BatteryState -> BatteryState -> BatteryState)
-> (BatteryState -> BatteryState -> BatteryState)
-> Ord BatteryState
BatteryState -> BatteryState -> Bool
BatteryState -> BatteryState -> Ordering
BatteryState -> BatteryState -> BatteryState
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: BatteryState -> BatteryState -> Ordering
compare :: BatteryState -> BatteryState -> Ordering
$c< :: BatteryState -> BatteryState -> Bool
< :: BatteryState -> BatteryState -> Bool
$c<= :: BatteryState -> BatteryState -> Bool
<= :: BatteryState -> BatteryState -> Bool
$c> :: BatteryState -> BatteryState -> Bool
> :: BatteryState -> BatteryState -> Bool
$c>= :: BatteryState -> BatteryState -> Bool
>= :: BatteryState -> BatteryState -> Bool
$cmax :: BatteryState -> BatteryState -> BatteryState
max :: BatteryState -> BatteryState -> BatteryState
$cmin :: BatteryState -> BatteryState -> BatteryState
min :: BatteryState -> BatteryState -> BatteryState
Ord, BatteryState -> BatteryState -> Bool
(BatteryState -> BatteryState -> Bool)
-> (BatteryState -> BatteryState -> Bool) -> Eq BatteryState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BatteryState -> BatteryState -> Bool
== :: BatteryState -> BatteryState -> Bool
$c/= :: BatteryState -> BatteryState -> Bool
/= :: BatteryState -> BatteryState -> Bool
Eq, Int -> BatteryState
BatteryState -> Int
BatteryState -> [BatteryState]
BatteryState -> BatteryState
BatteryState -> BatteryState -> [BatteryState]
BatteryState -> BatteryState -> BatteryState -> [BatteryState]
(BatteryState -> BatteryState)
-> (BatteryState -> BatteryState)
-> (Int -> BatteryState)
-> (BatteryState -> Int)
-> (BatteryState -> [BatteryState])
-> (BatteryState -> BatteryState -> [BatteryState])
-> (BatteryState -> BatteryState -> [BatteryState])
-> (BatteryState -> BatteryState -> BatteryState -> [BatteryState])
-> Enum BatteryState
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: BatteryState -> BatteryState
succ :: BatteryState -> BatteryState
$cpred :: BatteryState -> BatteryState
pred :: BatteryState -> BatteryState
$ctoEnum :: Int -> BatteryState
toEnum :: Int -> BatteryState
$cfromEnum :: BatteryState -> Int
fromEnum :: BatteryState -> Int
$cenumFrom :: BatteryState -> [BatteryState]
enumFrom :: BatteryState -> [BatteryState]
$cenumFromThen :: BatteryState -> BatteryState -> [BatteryState]
enumFromThen :: BatteryState -> BatteryState -> [BatteryState]
$cenumFromTo :: BatteryState -> BatteryState -> [BatteryState]
enumFromTo :: BatteryState -> BatteryState -> [BatteryState]
$cenumFromThenTo :: BatteryState -> BatteryState -> BatteryState -> [BatteryState]
enumFromThenTo :: BatteryState -> BatteryState -> BatteryState -> [BatteryState]
Enum)

data BatteryTechnology
  = BatteryTechnologyUnknown
  | BatteryTechnologyLithiumIon
  | BatteryTechnologyLithiumPolymer
  | BatteryTechnologyLithiumIronPhosphate
  | BatteryTechnologyLeadAcid
  | BatteryTechnologyNickelCadmium
  | BatteryTechnologyNickelMetalHydride
  deriving (Int -> BatteryTechnology -> ShowS
[BatteryTechnology] -> ShowS
BatteryTechnology -> String
(Int -> BatteryTechnology -> ShowS)
-> (BatteryTechnology -> String)
-> ([BatteryTechnology] -> ShowS)
-> Show BatteryTechnology
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BatteryTechnology -> ShowS
showsPrec :: Int -> BatteryTechnology -> ShowS
$cshow :: BatteryTechnology -> String
show :: BatteryTechnology -> String
$cshowList :: [BatteryTechnology] -> ShowS
showList :: [BatteryTechnology] -> ShowS
Show, Eq BatteryTechnology
Eq BatteryTechnology
-> (BatteryTechnology -> BatteryTechnology -> Ordering)
-> (BatteryTechnology -> BatteryTechnology -> Bool)
-> (BatteryTechnology -> BatteryTechnology -> Bool)
-> (BatteryTechnology -> BatteryTechnology -> Bool)
-> (BatteryTechnology -> BatteryTechnology -> Bool)
-> (BatteryTechnology -> BatteryTechnology -> BatteryTechnology)
-> (BatteryTechnology -> BatteryTechnology -> BatteryTechnology)
-> Ord BatteryTechnology
BatteryTechnology -> BatteryTechnology -> Bool
BatteryTechnology -> BatteryTechnology -> Ordering
BatteryTechnology -> BatteryTechnology -> BatteryTechnology
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: BatteryTechnology -> BatteryTechnology -> Ordering
compare :: BatteryTechnology -> BatteryTechnology -> Ordering
$c< :: BatteryTechnology -> BatteryTechnology -> Bool
< :: BatteryTechnology -> BatteryTechnology -> Bool
$c<= :: BatteryTechnology -> BatteryTechnology -> Bool
<= :: BatteryTechnology -> BatteryTechnology -> Bool
$c> :: BatteryTechnology -> BatteryTechnology -> Bool
> :: BatteryTechnology -> BatteryTechnology -> Bool
$c>= :: BatteryTechnology -> BatteryTechnology -> Bool
>= :: BatteryTechnology -> BatteryTechnology -> Bool
$cmax :: BatteryTechnology -> BatteryTechnology -> BatteryTechnology
max :: BatteryTechnology -> BatteryTechnology -> BatteryTechnology
$cmin :: BatteryTechnology -> BatteryTechnology -> BatteryTechnology
min :: BatteryTechnology -> BatteryTechnology -> BatteryTechnology
Ord, BatteryTechnology -> BatteryTechnology -> Bool
(BatteryTechnology -> BatteryTechnology -> Bool)
-> (BatteryTechnology -> BatteryTechnology -> Bool)
-> Eq BatteryTechnology
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BatteryTechnology -> BatteryTechnology -> Bool
== :: BatteryTechnology -> BatteryTechnology -> Bool
$c/= :: BatteryTechnology -> BatteryTechnology -> Bool
/= :: BatteryTechnology -> BatteryTechnology -> Bool
Eq, Int -> BatteryTechnology
BatteryTechnology -> Int
BatteryTechnology -> [BatteryTechnology]
BatteryTechnology -> BatteryTechnology
BatteryTechnology -> BatteryTechnology -> [BatteryTechnology]
BatteryTechnology
-> BatteryTechnology -> BatteryTechnology -> [BatteryTechnology]
(BatteryTechnology -> BatteryTechnology)
-> (BatteryTechnology -> BatteryTechnology)
-> (Int -> BatteryTechnology)
-> (BatteryTechnology -> Int)
-> (BatteryTechnology -> [BatteryTechnology])
-> (BatteryTechnology -> BatteryTechnology -> [BatteryTechnology])
-> (BatteryTechnology -> BatteryTechnology -> [BatteryTechnology])
-> (BatteryTechnology
    -> BatteryTechnology -> BatteryTechnology -> [BatteryTechnology])
-> Enum BatteryTechnology
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: BatteryTechnology -> BatteryTechnology
succ :: BatteryTechnology -> BatteryTechnology
$cpred :: BatteryTechnology -> BatteryTechnology
pred :: BatteryTechnology -> BatteryTechnology
$ctoEnum :: Int -> BatteryTechnology
toEnum :: Int -> BatteryTechnology
$cfromEnum :: BatteryTechnology -> Int
fromEnum :: BatteryTechnology -> Int
$cenumFrom :: BatteryTechnology -> [BatteryTechnology]
enumFrom :: BatteryTechnology -> [BatteryTechnology]
$cenumFromThen :: BatteryTechnology -> BatteryTechnology -> [BatteryTechnology]
enumFromThen :: BatteryTechnology -> BatteryTechnology -> [BatteryTechnology]
$cenumFromTo :: BatteryTechnology -> BatteryTechnology -> [BatteryTechnology]
enumFromTo :: BatteryTechnology -> BatteryTechnology -> [BatteryTechnology]
$cenumFromThenTo :: BatteryTechnology
-> BatteryTechnology -> BatteryTechnology -> [BatteryTechnology]
enumFromThenTo :: BatteryTechnology
-> BatteryTechnology -> BatteryTechnology -> [BatteryTechnology]
Enum)

batteryTypeForName :: GetTypeForName
batteryTypeForName :: GetTypeForName
batteryTypeForName String
name = Maybe Type -> Type -> Maybe Type
forall a b. a -> b -> a
const (Maybe Type -> Type -> Maybe Type)
-> Maybe Type -> Type -> Maybe Type
forall a b. (a -> b) -> a -> b
$
  case String
name of
    String
"Type" -> Name -> Maybe Type
yes ''BatteryType
    String
"State" -> Name -> Maybe Type
yes ''BatteryState
    String
"Technology" -> Name -> Maybe Type
yes ''BatteryTechnology
    String
_ -> Maybe Type
forall a. Maybe a
Nothing
  where yes :: Name -> Maybe Type
yes = Type -> Maybe Type
forall a. a -> Maybe a
Just (Type -> Maybe Type) -> (Name -> Type) -> Name -> Maybe Type
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> Type
ConT