{-# LANGUAGE CPP #-}
module Xmobar.Plugins.Monitors where
import Xmobar.Run.Exec
import Xmobar.Plugins.Monitors.Common (runM)
#ifdef WEATHER
import Xmobar.Plugins.Monitors.Weather
#endif
import Xmobar.Plugins.Monitors.Net
import Xmobar.Plugins.Monitors.Mem
import Xmobar.Plugins.Monitors.Swap
import Xmobar.Plugins.Monitors.Cpu
import Xmobar.Plugins.Monitors.MultiCpu
import Xmobar.Plugins.Monitors.Batt
import Xmobar.Plugins.Monitors.Bright
import Xmobar.Plugins.Monitors.Load
import Xmobar.Plugins.Monitors.Thermal
import Xmobar.Plugins.Monitors.ThermalZone
import Xmobar.Plugins.Monitors.CpuFreq
import Xmobar.Plugins.Monitors.CoreTemp
import Xmobar.Plugins.Monitors.MultiCoreTemp
import Xmobar.Plugins.Monitors.K10Temp
import Xmobar.Plugins.Monitors.Disk
import Xmobar.Plugins.Monitors.Top
import Xmobar.Plugins.Monitors.Uptime
import Xmobar.Plugins.Monitors.CatInt
#ifdef UVMETER
import Xmobar.Plugins.Monitors.UVMeter
#endif
#if defined IWLIB || defined USE_NL80211
import Xmobar.Plugins.Monitors.Wireless
#endif
#ifdef LIBMPD
import Xmobar.Plugins.Monitors.MPD
import Xmobar.Plugins.Monitors.Common (runMBD, runMD)
#endif
#ifdef ALSA
import Xmobar.Plugins.Monitors.Volume
import Xmobar.Plugins.Monitors.Alsa
#endif
#ifdef MPRIS
import Xmobar.Plugins.Monitors.Mpris
#endif
data Monitors = Network Interface Args Rate
| DynNetwork Args Rate
| BatteryP Args Args Rate
| BatteryN Args Args Rate Alias
| Battery Args Rate
| DiskU DiskSpec Args Rate
| DiskIO DiskSpec Args Rate
| Load Args Rate
| Thermal Zone Args Rate
| ThermalZone ZoneNo Args Rate
| Memory Args Rate
| Swap Args Rate
| Cpu Args Rate
| MultiCpu Args Rate
| Brightness Args Rate
| CpuFreq Args Rate
| CoreTemp Args Rate
| MultiCoreTemp Args Rate
| K10Temp Slot Args Rate
| TopProc Args Rate
| TopMem Args Rate
| Uptime Args Rate
| CatInt Int FilePath Args Rate
#ifdef WEATHER
| Weather Station Args Rate
| WeatherX Station SkyConditions Args Rate
#endif
#ifdef UVMETER
| UVMeter Station Args Rate
#endif
#if defined IWLIB || defined USE_NL80211
| Wireless Interface Args Rate
#endif
#ifdef LIBMPD
| MPD Args Rate
| MPDX Args Rate Alias
| AutoMPD Args
#endif
#ifdef ALSA
| Volume String String Args Rate
| Alsa String String Args
#endif
#ifdef MPRIS
| Mpris1 String Args Rate
| Mpris2 String Args Rate
#endif
deriving (Int -> Monitors -> ShowS
[Monitors] -> ShowS
Monitors -> String
(Int -> Monitors -> ShowS)
-> (Monitors -> String) -> ([Monitors] -> ShowS) -> Show Monitors
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Monitors -> ShowS
showsPrec :: Int -> Monitors -> ShowS
$cshow :: Monitors -> String
show :: Monitors -> String
$cshowList :: [Monitors] -> ShowS
showList :: [Monitors] -> ShowS
Show,ReadPrec [Monitors]
ReadPrec Monitors
Int -> ReadS Monitors
ReadS [Monitors]
(Int -> ReadS Monitors)
-> ReadS [Monitors]
-> ReadPrec Monitors
-> ReadPrec [Monitors]
-> Read Monitors
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Monitors
readsPrec :: Int -> ReadS Monitors
$creadList :: ReadS [Monitors]
readList :: ReadS [Monitors]
$creadPrec :: ReadPrec Monitors
readPrec :: ReadPrec Monitors
$creadListPrec :: ReadPrec [Monitors]
readListPrec :: ReadPrec [Monitors]
Read,Monitors -> Monitors -> Bool
(Monitors -> Monitors -> Bool)
-> (Monitors -> Monitors -> Bool) -> Eq Monitors
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Monitors -> Monitors -> Bool
== :: Monitors -> Monitors -> Bool
$c/= :: Monitors -> Monitors -> Bool
/= :: Monitors -> Monitors -> Bool
Eq)
type Args = [String]
type Program = String
type Alias = String
type Station = String
type SkyConditions = [(String, String)]
type Zone = String
type ZoneNo = Int
type Interface = String
type Rate = Int
type DiskSpec = [(String, String)]
type Slot = String
instance Exec Monitors where
#ifdef WEATHER
alias :: Monitors -> String
alias (Weather String
s [String]
_ Int
_) = String
s
alias (WeatherX String
s [(String, String)]
_ [String]
_ Int
_) = String
s
#endif
alias (Network String
i [String]
_ Int
_) = String
i
alias (DynNetwork [String]
_ Int
_) = String
"dynnetwork"
alias (Load [String]
_ Int
_) = String
"load"
alias (Thermal String
z [String]
_ Int
_) = String
z
alias (ThermalZone Int
z [String]
_ Int
_) = String
"thermal" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
z
alias (Memory [String]
_ Int
_) = String
"memory"
alias (Swap [String]
_ Int
_) = String
"swap"
alias (Cpu [String]
_ Int
_) = String
"cpu"
alias (MultiCpu [String]
_ Int
_) = String
"multicpu"
alias (Battery [String]
_ Int
_) = String
"battery"
alias BatteryP {} = String
"battery"
alias (BatteryN [String]
_ [String]
_ Int
_ String
a)= String
a
alias (Brightness [String]
_ Int
_) = String
"bright"
alias (CpuFreq [String]
_ Int
_) = String
"cpufreq"
alias (TopProc [String]
_ Int
_) = String
"top"
alias (TopMem [String]
_ Int
_) = String
"topmem"
alias (CoreTemp [String]
_ Int
_) = String
"coretemp"
alias (MultiCoreTemp [String]
_ Int
_) = String
"multicoretemp"
alias K10Temp {} = String
"k10temp"
alias DiskU {} = String
"disku"
alias DiskIO {} = String
"diskio"
alias (Uptime [String]
_ Int
_) = String
"uptime"
alias (CatInt Int
n String
_ [String]
_ Int
_) = String
"cat" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show Int
n
#ifdef UVMETER
alias (UVMeter s _ _) = "uv " ++ s
#endif
#if defined IWLIB || defined USE_NL80211
alias (Wireless String
i [String]
_ Int
_) = String
i String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"wi"
#endif
#ifdef LIBMPD
alias (MPD [String]
_ Int
_) = String
"mpd"
alias (AutoMPD [String]
_) = String
"autompd"
alias (MPDX [String]
_ Int
_ String
a) = String
a
#endif
#ifdef ALSA
alias (Volume String
m String
c [String]
_ Int
_) = String
m String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
":" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
c
alias (Alsa String
m String
c [String]
_) = String
"alsa:" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
m String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
":" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
c
#endif
#ifdef MPRIS
alias (Mpris1 String
_ [String]
_ Int
_) = String
"mpris1"
alias (Mpris2 String
_ [String]
_ Int
_) = String
"mpris2"
#endif
start :: Monitors -> (String -> IO ()) -> IO ()
start (Network String
i [String]
a Int
r) = String -> [String] -> Int -> (String -> IO ()) -> IO ()
startNet String
i [String]
a Int
r
start (DynNetwork [String]
a Int
r) = [String] -> Int -> (String -> IO ()) -> IO ()
startDynNet [String]
a Int
r
start (Cpu [String]
a Int
r) = [String] -> Int -> (String -> IO ()) -> IO ()
startCpu [String]
a Int
r
start (MultiCpu [String]
a Int
r) = [String] -> Int -> (String -> IO ()) -> IO ()
startMultiCpu [String]
a Int
r
start (TopProc [String]
a Int
r) = [String] -> Int -> (String -> IO ()) -> IO ()
startTop [String]
a Int
r
start (TopMem [String]
a Int
r) = [String]
-> IO MConfig
-> ([String] -> Monitor String)
-> Int
-> (String -> IO ())
-> IO ()
runM [String]
a IO MConfig
topMemConfig [String] -> Monitor String
runTopMem Int
r
#ifdef WEATHER
start (Weather String
s [String]
a Int
r) = String -> [String] -> Int -> (String -> IO ()) -> IO ()
startWeather String
s [String]
a Int
r
start (WeatherX String
s [(String, String)]
c [String]
a Int
r) = [(String, String)]
-> String -> [String] -> Int -> (String -> IO ()) -> IO ()
startWeather' [(String, String)]
c String
s [String]
a Int
r
#endif
start (Thermal String
z [String]
a Int
r) = [String]
-> IO MConfig
-> ([String] -> Monitor String)
-> Int
-> (String -> IO ())
-> IO ()
runM ([String]
a [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String
z]) IO MConfig
thermalConfig [String] -> Monitor String
runThermal Int
r
start (ThermalZone Int
z [String]
a Int
r) =
[String]
-> IO MConfig
-> ([String] -> Monitor String)
-> Int
-> (String -> IO ())
-> IO ()
runM ([String]
a [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [Int -> String
forall a. Show a => a -> String
show Int
z]) IO MConfig
thermalZoneConfig [String] -> Monitor String
runThermalZone Int
r
start (Load [String]
a Int
r) = [String]
-> IO MConfig
-> ([String] -> Monitor String)
-> Int
-> (String -> IO ())
-> IO ()
runM [String]
a IO MConfig
loadConfig [String] -> Monitor String
runLoad Int
r
start (Memory [String]
a Int
r) = [String]
-> IO MConfig
-> ([String] -> Monitor String)
-> Int
-> (String -> IO ())
-> IO ()
runM [String]
a IO MConfig
memConfig [String] -> Monitor String
runMem Int
r
start (Swap [String]
a Int
r) = [String]
-> IO MConfig
-> ([String] -> Monitor String)
-> Int
-> (String -> IO ())
-> IO ()
runM [String]
a IO MConfig
swapConfig [String] -> Monitor String
runSwap Int
r
start (Battery [String]
a Int
r) = [String]
-> IO MConfig
-> ([String] -> Monitor String)
-> Int
-> (String -> IO ())
-> IO ()
runM [String]
a IO MConfig
battConfig [String] -> Monitor String
runBatt Int
r
start (BatteryP [String]
s [String]
a Int
r) = [String]
-> IO MConfig
-> ([String] -> Monitor String)
-> Int
-> (String -> IO ())
-> IO ()
runM [String]
a IO MConfig
battConfig ([String] -> [String] -> Monitor String
runBatt' [String]
s) Int
r
start (BatteryN [String]
s [String]
a Int
r String
_) = [String]
-> IO MConfig
-> ([String] -> Monitor String)
-> Int
-> (String -> IO ())
-> IO ()
runM [String]
a IO MConfig
battConfig ([String] -> [String] -> Monitor String
runBatt' [String]
s) Int
r
start (Brightness [String]
a Int
r) = [String]
-> IO MConfig
-> ([String] -> Monitor String)
-> Int
-> (String -> IO ())
-> IO ()
runM [String]
a IO MConfig
brightConfig [String] -> Monitor String
runBright Int
r
start (CpuFreq [String]
a Int
r) = [String]
-> IO MConfig
-> ([String] -> Monitor String)
-> Int
-> (String -> IO ())
-> IO ()
runM [String]
a IO MConfig
cpuFreqConfig [String] -> Monitor String
runCpuFreq Int
r
start (CoreTemp [String]
a Int
r) = [String]
-> IO MConfig
-> ([String] -> Monitor String)
-> Int
-> (String -> IO ())
-> IO ()
runM [String]
a IO MConfig
coreTempConfig [String] -> Monitor String
runCoreTemp Int
r
start (MultiCoreTemp [String]
a Int
r) = [String] -> Int -> (String -> IO ()) -> IO ()
startMultiCoreTemp [String]
a Int
r
start (K10Temp String
s [String]
a Int
r) = [String]
-> IO MConfig
-> ([String] -> Monitor String)
-> Int
-> (String -> IO ())
-> IO ()
runM ([String]
a [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String
s]) IO MConfig
k10TempConfig [String] -> Monitor String
runK10Temp Int
r
start (DiskU [(String, String)]
s [String]
a Int
r) = [String]
-> IO MConfig
-> ([String] -> Monitor String)
-> Int
-> (String -> IO ())
-> IO ()
runM [String]
a IO MConfig
diskUConfig ([(String, String)] -> [String] -> Monitor String
runDiskU [(String, String)]
s) Int
r
start (DiskIO [(String, String)]
s [String]
a Int
r) = [(String, String)] -> [String] -> Int -> (String -> IO ()) -> IO ()
startDiskIO [(String, String)]
s [String]
a Int
r
start (Uptime [String]
a Int
r) = [String]
-> IO MConfig
-> ([String] -> Monitor String)
-> Int
-> (String -> IO ())
-> IO ()
runM [String]
a IO MConfig
uptimeConfig [String] -> Monitor String
runUptime Int
r
start (CatInt Int
_ String
s [String]
a Int
r) = [String]
-> IO MConfig
-> ([String] -> Monitor String)
-> Int
-> (String -> IO ())
-> IO ()
runM [String]
a IO MConfig
catIntConfig (String -> [String] -> Monitor String
runCatInt String
s) Int
r
#ifdef UVMETER
start (UVMeter s a r) = startUVMeter s a r
#endif
#if defined IWLIB || defined USE_NL80211
start (Wireless String
i [String]
a Int
r) = [String]
-> IO MConfig
-> ([String] -> Monitor String)
-> Int
-> (String -> IO ())
-> IO ()
runM [String]
a IO MConfig
wirelessConfig (String -> [String] -> Monitor String
runWireless String
i) Int
r
#endif
#ifdef LIBMPD
start (MPD [String]
a Int
r) = [String]
-> IO MConfig
-> ([String] -> Monitor String)
-> Int
-> ([String] -> Monitor Bool)
-> (String -> IO ())
-> IO ()
runMD [String]
a IO MConfig
mpdConfig [String] -> Monitor String
runMPD Int
r [String] -> Monitor Bool
mpdReady
start (MPDX [String]
a Int
r String
_) = Monitors -> (String -> IO ()) -> IO ()
forall e. Exec e => e -> (String -> IO ()) -> IO ()
start ([String] -> Int -> Monitors
MPD [String]
a Int
r)
start (AutoMPD [String]
a) = [String]
-> IO MConfig
-> ([String] -> Monitor String)
-> IO ()
-> ([String] -> Monitor Bool)
-> (String -> IO ())
-> IO ()
runMBD [String]
a IO MConfig
mpdConfig [String] -> Monitor String
runMPD IO ()
mpdWait [String] -> Monitor Bool
mpdReady
#endif
#ifdef ALSA
start (Volume String
m String
c [String]
a Int
r) = [String]
-> IO MConfig
-> ([String] -> Monitor String)
-> Int
-> (String -> IO ())
-> IO ()
runM [String]
a IO MConfig
volumeConfig (String -> String -> [String] -> Monitor String
runVolume String
m String
c) Int
r
start (Alsa String
m String
c [String]
a) = String -> String -> [String] -> (String -> IO ()) -> IO ()
startAlsaPlugin String
m String
c [String]
a
#endif
#ifdef MPRIS
start (Mpris1 String
s [String]
a Int
r) = [String]
-> IO MConfig
-> ([String] -> Monitor String)
-> Int
-> (String -> IO ())
-> IO ()
runM [String]
a IO MConfig
mprisConfig (String -> [String] -> Monitor String
runMPRIS1 String
s) Int
r
start (Mpris2 String
s [String]
a Int
r) = [String]
-> IO MConfig
-> ([String] -> Monitor String)
-> Int
-> (String -> IO ())
-> IO ()
runM [String]
a IO MConfig
mprisConfig (String -> [String] -> Monitor String
runMPRIS2 String
s) Int
r
#endif