summaryrefslogtreecommitdiffhomepage
path: root/Plugins/Monitors.hs
blob: 4943b69a9d72cc39aa0b8f23f8b733c9c93f5ac8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
-----------------------------------------------------------------------------
-- |
-- Module      :  Xmobar.Plugins.Monitors
-- Copyright   :  (c) Andrea Rossato
-- License     :  BSD-style (see LICENSE)
--
-- Maintainer  :  Andrea Rossato <andrea.rossato@unibz.it>
-- Stability   :  unstable
-- Portability :  unportable
--
-- The system monitor plugin for Xmobar.
--
-----------------------------------------------------------------------------

module Plugins.Monitors where

import Plugins

import Plugins.Monitors.Common ( runM )
import Plugins.Monitors.Weather
import Plugins.Monitors.Net
import Plugins.Monitors.Mem
import Plugins.Monitors.Swap
import Plugins.Monitors.Cpu
import Plugins.Monitors.MultiCpu
import Plugins.Monitors.Batt
import Plugins.Monitors.Thermal
import Plugins.Monitors.CpuFreq
import Plugins.Monitors.CoreTemp
import Plugins.Monitors.Disk

data Monitors = Weather  Station    Args Rate
              | Network  Interface  Args Rate
              | Memory   Args       Rate
              | Swap     Args       Rate
              | Cpu      Args       Rate
              | MultiCpu Args       Rate
              | Battery  Args       Rate
              | BatteryP [String]   Args Rate
              | Disk     DiskSpec   Args Rate
              | Thermal  Zone       Args Rate
              | CpuFreq  Args       Rate
              | CoreTemp Args       Rate
                deriving (Show,Read,Eq)

type Args      = [String]
type Program   = String
type Alias     = String
type Station   = String
type Zone      = String
type Interface = String
type Rate      = Int
type DiskSpec  = [(String, String)]

instance Exec Monitors where
    alias (Weather  s _ _) = s
    alias (Network  i _ _) = i
    alias (Thermal  z _ _) = z
    alias (Memory     _ _) = "memory"
    alias (Swap       _ _) = "swap"
    alias (Cpu        _ _) = "cpu"
    alias (MultiCpu   _ _) = "multicpu"
    alias (Battery    _ _) = "battery"
    alias (BatteryP  _ _ _)= "battery"
    alias (CpuFreq    _ _) = "cpufreq"
    alias (CoreTemp   _ _) = "coretemp"
    alias (Disk     _ _ _) = "disk"
    start (Weather  s a r) = runM (a ++ [s]) weatherConfig  runWeather  r
    start (Network  i a r) = runM (a ++ [i]) netConfig      runNet      r
    start (Thermal  z a r) = runM (a ++ [z]) thermalConfig  runThermal  r
    start (Memory     a r) = runM a          memConfig      runMem      r
    start (Swap       a r) = runM a          swapConfig     runSwap     r
    start (Cpu        a r) = runM a          cpuConfig      runCpu      r
    start (MultiCpu   a r) = runM a          multiCpuConfig runMultiCpu r
    start (Battery    a r) = runM a          battConfig     runBatt     r
    start (BatteryP s a r) = runM a          battConfig    (runBatt' s) r
    start (CpuFreq    a r) = runM a          cpuFreqConfig  runCpuFreq  r
    start (CoreTemp   a r) = runM a          coreTempConfig runCoreTemp r
    start (Disk     s a r) = runM a          diskConfig     (runDisk s) r