1{-# LANGUAGE CPP #-} 2 3----------------------------------------------------------------------------- 4-- | 5-- Module : Xmobar.Plugins.Monitors 6-- Copyright : (c) 2010, 2011, 2012, 2013, 2017, 2018, 2019, 2020 Jose Antonio Ortega Ruiz 7-- (c) 2007-10 Andrea Rossato 8-- License : BSD-style (see LICENSE) 9-- 10-- Maintainer : Jose A. Ortega Ruiz <jao@gnu.org> 11-- Stability : unstable 12-- Portability : unportable 13-- 14-- The system monitor plugin for Xmobar. 15-- 16----------------------------------------------------------------------------- 17 18module Xmobar.Plugins.Monitors where 19 20import Xmobar.Run.Exec 21 22import Xmobar.Plugins.Monitors.Common (runM) 23#ifdef WEATHER 24import Xmobar.Plugins.Monitors.Weather 25#endif 26import Xmobar.Plugins.Monitors.Net 27import Xmobar.Plugins.Monitors.Mem 28import Xmobar.Plugins.Monitors.Swap 29import Xmobar.Plugins.Monitors.Cpu 30import Xmobar.Plugins.Monitors.MultiCpu 31import Xmobar.Plugins.Monitors.Batt 32import Xmobar.Plugins.Monitors.Bright 33import Xmobar.Plugins.Monitors.Thermal 34import Xmobar.Plugins.Monitors.ThermalZone 35import Xmobar.Plugins.Monitors.CpuFreq 36import Xmobar.Plugins.Monitors.CoreTemp 37import Xmobar.Plugins.Monitors.MultiCoreTemp 38import Xmobar.Plugins.Monitors.K10Temp 39import Xmobar.Plugins.Monitors.Disk 40import Xmobar.Plugins.Monitors.Top 41import Xmobar.Plugins.Monitors.Uptime 42import Xmobar.Plugins.Monitors.CatInt 43#ifdef UVMETER 44import Xmobar.Plugins.Monitors.UVMeter 45#endif 46#if defined IWLIB || defined USE_NL80211 47import Xmobar.Plugins.Monitors.Wireless 48#endif 49#ifdef LIBMPD 50import Xmobar.Plugins.Monitors.MPD 51import Xmobar.Plugins.Monitors.Common (runMBD, runMD) 52#endif 53#ifdef ALSA 54import Xmobar.Plugins.Monitors.Volume 55import Xmobar.Plugins.Monitors.Alsa 56#endif 57#ifdef MPRIS 58import Xmobar.Plugins.Monitors.Mpris 59#endif 60 61data Monitors = Network Interface Args Rate 62 | DynNetwork Args Rate 63 | BatteryP Args Args Rate 64 | BatteryN Args Args Rate Alias 65 | Battery Args Rate 66 | DiskU DiskSpec Args Rate 67 | DiskIO DiskSpec Args Rate 68 | Thermal Zone Args Rate 69 | ThermalZone ZoneNo Args Rate 70 | Memory Args Rate 71 | Swap Args Rate 72 | Cpu Args Rate 73 | MultiCpu Args Rate 74 | Brightness Args Rate 75 | CpuFreq Args Rate 76 | CoreTemp Args Rate 77 | MultiCoreTemp Args Rate 78 | K10Temp Slot Args Rate 79 | TopProc Args Rate 80 | TopMem Args Rate 81 | Uptime Args Rate 82 | CatInt Int FilePath Args Rate 83#ifdef WEATHER 84 | Weather Station Args Rate 85 | WeatherX Station SkyConditions Args Rate 86#endif 87#ifdef UVMETER 88 | UVMeter Station Args Rate 89#endif 90#if defined IWLIB || defined USE_NL80211 91 | Wireless Interface Args Rate 92#endif 93#ifdef LIBMPD 94 | MPD Args Rate 95 | MPDX Args Rate Alias 96 | AutoMPD Args 97#endif 98#ifdef ALSA 99 | Volume String String Args Rate 100 | Alsa String String Args 101#endif 102#ifdef MPRIS 103 | Mpris1 String Args Rate 104 | Mpris2 String Args Rate 105#endif 106 deriving (Show,Read,Eq) 107 108type Args = [String] 109type Program = String 110type Alias = String 111type Station = String 112type SkyConditions = [(String, String)] 113type Zone = String 114type ZoneNo = Int 115type Interface = String 116type Rate = Int 117type DiskSpec = [(String, String)] 118type Slot = String 119 120instance Exec Monitors where 121#ifdef WEATHER 122 alias (Weather s _ _) = s 123 alias (WeatherX s _ _ _) = s 124#endif 125 alias (Network i _ _) = i 126 alias (DynNetwork _ _) = "dynnetwork" 127 alias (Thermal z _ _) = z 128 alias (ThermalZone z _ _) = "thermal" ++ show z 129 alias (Memory _ _) = "memory" 130 alias (Swap _ _) = "swap" 131 alias (Cpu _ _) = "cpu" 132 alias (MultiCpu _ _) = "multicpu" 133 alias (Battery _ _) = "battery" 134 alias BatteryP {} = "battery" 135 alias (BatteryN _ _ _ a)= a 136 alias (Brightness _ _) = "bright" 137 alias (CpuFreq _ _) = "cpufreq" 138 alias (TopProc _ _) = "top" 139 alias (TopMem _ _) = "topmem" 140 alias (CoreTemp _ _) = "coretemp" 141 alias (MultiCoreTemp _ _) = "multicoretemp" 142 alias K10Temp {} = "k10temp" 143 alias DiskU {} = "disku" 144 alias DiskIO {} = "diskio" 145 alias (Uptime _ _) = "uptime" 146 alias (CatInt n _ _ _) = "cat" ++ show n 147#ifdef UVMETER 148 alias (UVMeter s _ _) = "uv " ++ s 149#endif 150#if defined IWLIB || defined USE_NL80211 151 alias (Wireless i _ _) = i ++ "wi" 152#endif 153#ifdef LIBMPD 154 alias (MPD _ _) = "mpd" 155 alias (AutoMPD _) = "autompd" 156 alias (MPDX _ _ a) = a 157#endif 158#ifdef ALSA 159 alias (Volume m c _ _) = m ++ ":" ++ c 160 alias (Alsa m c _) = "alsa:" ++ m ++ ":" ++ c 161#endif 162#ifdef MPRIS 163 alias (Mpris1 _ _ _) = "mpris1" 164 alias (Mpris2 _ _ _) = "mpris2" 165#endif 166 start (Network i a r) = startNet i a r 167 start (DynNetwork a r) = startDynNet a r 168 start (Cpu a r) = startCpu a r 169 start (MultiCpu a r) = startMultiCpu a r 170 start (TopProc a r) = startTop a r 171 start (TopMem a r) = runM a topMemConfig runTopMem r 172#ifdef WEATHER 173 start (Weather s a r) = startWeather s a r 174 start (WeatherX s c a r) = startWeather' c s a r 175#endif 176 start (Thermal z a r) = runM (a ++ [z]) thermalConfig runThermal r 177 start (ThermalZone z a r) = 178 runM (a ++ [show z]) thermalZoneConfig runThermalZone r 179 start (Memory a r) = runM a memConfig runMem r 180 start (Swap a r) = runM a swapConfig runSwap r 181 start (Battery a r) = runM a battConfig runBatt r 182 start (BatteryP s a r) = runM a battConfig (runBatt' s) r 183 start (BatteryN s a r _) = runM a battConfig (runBatt' s) r 184 start (Brightness a r) = runM a brightConfig runBright r 185 start (CpuFreq a r) = runM a cpuFreqConfig runCpuFreq r 186 start (CoreTemp a r) = runM a coreTempConfig runCoreTemp r 187 start (MultiCoreTemp a r) = startMultiCoreTemp a r 188 start (K10Temp s a r) = runM (a ++ [s]) k10TempConfig runK10Temp r 189 start (DiskU s a r) = runM a diskUConfig (runDiskU s) r 190 start (DiskIO s a r) = startDiskIO s a r 191 start (Uptime a r) = runM a uptimeConfig runUptime r 192 start (CatInt _ s a r) = runM a catIntConfig (runCatInt s) r 193#ifdef UVMETER 194 start (UVMeter s a r) = startUVMeter s a r 195#endif 196#if defined IWLIB || defined USE_NL80211 197 start (Wireless i a r) = runM a wirelessConfig (runWireless i) r 198#endif 199#ifdef LIBMPD 200 start (MPD a r) = runMD a mpdConfig runMPD r mpdReady 201 start (MPDX a r _) = start (MPD a r) 202 start (AutoMPD a) = runMBD a mpdConfig runMPD mpdWait mpdReady 203#endif 204#ifdef ALSA 205 start (Volume m c a r) = runM a volumeConfig (runVolume m c) r 206 start (Alsa m c a) = startAlsaPlugin m c a 207#endif 208#ifdef MPRIS 209 start (Mpris1 s a r) = runM a mprisConfig (runMPRIS1 s) r 210 start (Mpris2 s a r) = runM a mprisConfig (runMPRIS2 s) r 211#endif 212