summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--NEWS4
-rw-r--r--README29
-rw-r--r--src/Plugins/Monitors.hs75
-rw-r--r--src/Plugins/Monitors/ThermalZone.hs43
4 files changed, 112 insertions, 39 deletions
diff --git a/NEWS b/NEWS
index 59accbd..03934d9 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,9 @@ _New features_
- New `Volume` monitor displaying ALSA soundcards information, by
Thomas Tuegel.
+ - New `ThermalZone` plugin substituting `Thermal` and using linux's
+ *sysfs* interface (you need this one if you're using a kernel
+ version equal to or above 2.6.37). See [issue 44].
- xmobar app new has WM_CLASS, WM_NAME and _NET_WM_PID xprops
([issue 38]).
@@ -40,6 +43,7 @@ _Bug fixes_
[issue 38]: http://code.google.com/p/xmobar/issues/detail?id=38
[issue 40]: http://code.google.com/p/xmobar/issues/detail?id=40
[issue 42]: http://code.google.com/p/xmobar/issues/detail?id=42
+[issue 44]: http://code.google.com/p/xmobar/issues/detail?id=44
## Version 0.12 (Dec 24, 2010)
diff --git a/README b/README
index 920ba9c..3bb4a6b 100644
--- a/README
+++ b/README
@@ -317,9 +317,9 @@ standard input reader, an Unix named pipe reader, and a configurable
date plugin. These plugins install the following internal commands:
`Weather`, `Network`, `Wireless` (optional), `Memory`, `Swap`, `Cpu`,
`MultiCpu`, `Battery`, `TopProc`, `TopMem`, `DiskU`, `DiskIO`,
-`Thermal`, `CpuFreq`, `CoreTemp`, `Volume` (optional), `MPD`
-(optional), `Mail` (optional), `MBox` (optional), `Date`, `Uptime`,
-`StdinReader`, `CommandReader`, and `PipeReader`.
+`Thermal`, `ThermalZone`, `CpuFreq`, `CoreTemp`, `Volume` (optional),
+`MPD` (optional), `Mail` (optional), `MBox` (optional), `Date`,
+`Uptime`, `StdinReader`, `CommandReader`, and `PipeReader`.
To remove them see below Installing/Removing a Plugin
@@ -515,9 +515,28 @@ Monitors have default aliases.
Disks [("/", "<read> <write>"), ("sdb1", "<total>")] [] 10
+`ThermalZone Number Args RefreshRate`
+
+- Aliases to "thermaln": so `ThermalZone 0 []` can be used in template
+ as `%thermal0%`
+- Args: default monitor arguments (see below)
+- Variables that can be used with the `-t`/`--template` argument:
+ `temp`
+- Default template: `<temp>C`
+- This plugin works only on sytems with devices having thermal zone.
+ Check directories in `/sys/class/thermal` for possible values of the
+ zone number (e.g., 0 corresponds to `thermal_zone0` in that
+ directory).
+- Example:
+
+ Run ThermalZone 0 ["-t","<id>: <temp>C"] 30
+
`Thermal Zone Args RefreshRate`
-- Aliases to the Zone: so `Zone "THRM" []` can be used in template as `%THRM%`
+- **This plugin is deprecated. Use `ThermalZone` instead.**
+
+- Aliases to the Zone: so `Thermal "THRM" []` can be used in template
+ as `%THRM%`
- Args: default monitor arguments (see below)
- Variables that can be used with the `-t`/`--template` argument:
`temp`
@@ -526,7 +545,7 @@ Monitors have default aliases.
Check directories in /proc/acpi/thermal_zone for possible values.
- Example:
- Run Thermal "THRM" ["-t","iwl4965-temp: <temp>C"]
+ Run Thermal "THRM" ["-t","iwl4965-temp: <temp>C"] 50
`CpuFreq Args RefreshRate`
diff --git a/src/Plugins/Monitors.hs b/src/Plugins/Monitors.hs
index 4f1795b..2b09ac1 100644
--- a/src/Plugins/Monitors.hs
+++ b/src/Plugins/Monitors.hs
@@ -3,7 +3,8 @@
-----------------------------------------------------------------------------
-- |
-- Module : Xmobar.Plugins.Monitors
--- Copyright : (c) Andrea Rossato
+-- Copyright : (c) 2010, 2011 Jose Antonio Ortega Ruiz
+ (c) 2007-10 Andrea Rossato
-- License : BSD-style (see LICENSE)
--
-- Maintainer : Jose A. Ortega Ruiz <jao@gnu.org>
@@ -27,6 +28,7 @@ import Plugins.Monitors.Cpu
import Plugins.Monitors.MultiCpu
import Plugins.Monitors.Batt
import Plugins.Monitors.Thermal
+import Plugins.Monitors.ThermalZone
import Plugins.Monitors.CpuFreq
import Plugins.Monitors.CoreTemp
import Plugins.Monitors.Disk
@@ -42,22 +44,23 @@ import Plugins.Monitors.MPD
import Plugins.Monitors.Volume
#endif
-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
- | DiskU DiskSpec Args Rate
- | DiskIO DiskSpec Args Rate
- | Thermal Zone Args Rate
- | CpuFreq Args Rate
- | CoreTemp Args Rate
- | TopProc Args Rate
- | TopMem Args Rate
- | Uptime Args Rate
+data Monitors = Weather Station Args Rate
+ | Network Interface Args Rate
+ | BatteryP [String] Args Rate
+ | DiskU DiskSpec Args Rate
+ | DiskIO DiskSpec Args Rate
+ | Thermal Zone Args Rate
+ | ThermalZone ZoneNo Args Rate
+ | Memory Args Rate
+ | Swap Args Rate
+ | Cpu Args Rate
+ | MultiCpu Args Rate
+ | Battery Args Rate
+ | CpuFreq Args Rate
+ | CoreTemp Args Rate
+ | TopProc Args Rate
+ | TopMem Args Rate
+ | Uptime Args Rate
#ifdef IWLIB
| Wireless Interface Args Rate
#endif
@@ -74,32 +77,34 @@ type Program = String
type Alias = String
type Station = String
type Zone = String
+type ZoneNo = Int
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 (TopProc _ _) = "top"
- alias (TopMem _ _) = "topmem"
- alias (CoreTemp _ _) = "coretemp"
- alias (DiskU _ _ _) = "disku"
- alias (DiskIO _ _ _) = "diskio"
- alias (Uptime _ _) = "uptime"
+ alias (Weather s _ _) = s
+ alias (Network i _ _) = i
+ alias (Thermal z _ _) = z
+ alias (ThermalZone z _ _) = "thermal" ++ show z
+ alias (Memory _ _) = "memory"
+ alias (Swap _ _) = "swap"
+ alias (Cpu _ _) = "cpu"
+ alias (MultiCpu _ _) = "multicpu"
+ alias (Battery _ _) = "battery"
+ alias (BatteryP _ _ _)= "battery"
+ alias (CpuFreq _ _) = "cpufreq"
+ alias (TopProc _ _) = "top"
+ alias (TopMem _ _) = "topmem"
+ alias (CoreTemp _ _) = "coretemp"
+ alias (DiskU _ _ _) = "disku"
+ alias (DiskIO _ _ _) = "diskio"
+ alias (Uptime _ _) = "uptime"
#ifdef IWLIB
alias (Wireless i _ _) = i ++ "wi"
#endif
#ifdef LIBMPD
- alias (MPD _ _) = "mpd"
+ alias (MPD _ _) = "mpd"
#endif
#ifdef ALSA
alias (Volume m c _ _) = m ++ ":" ++ c
@@ -111,6 +116,8 @@ instance Exec Monitors where
start (TopMem a r) = runM a topMemConfig runTopMem r
start (Weather s a r) = runM (a ++ [s]) weatherConfig runWeather r
start (Thermal z a r) = runM (a ++ [z]) thermalConfig runThermal r
+ start (ThermalZone z a r) =
+ runM (a ++ [show z]) thermalZoneConfig runThermalZone r
start (Memory a r) = runM a memConfig runMem r
start (Swap a r) = runM a swapConfig runSwap r
start (Battery a r) = runM a battConfig runBatt r
diff --git a/src/Plugins/Monitors/ThermalZone.hs b/src/Plugins/Monitors/ThermalZone.hs
new file mode 100644
index 0000000..8ba858a
--- /dev/null
+++ b/src/Plugins/Monitors/ThermalZone.hs
@@ -0,0 +1,43 @@
+------------------------------------------------------------------------------
+-- |
+-- Module : Plugins.Monitors.ThermalZone
+-- Copyright : (c) 2011 Jose Antonio Ortega Ruiz
+-- License : BSD3-style (see LICENSE)
+--
+-- Maintainer : jao@gnu.org
+-- Stability : unstable
+-- Portability : portable
+-- Created : Fri Feb 25, 2011 03:18
+--
+--
+-- A thermal zone plugin based on the sysfs linux interface.
+-- See http://www.mjmwired.net/kernel/Documentation/thermal/sysfs-api.txt
+--
+------------------------------------------------------------------------------
+
+module Plugins.Monitors.ThermalZone (thermalZoneConfig, runThermalZone) where
+
+import Plugins.Monitors.Common
+
+import System.Posix.Files (fileExist)
+import qualified Data.ByteString.Char8 as B
+
+-- | Default thermal configuration.
+thermalZoneConfig :: IO MConfig
+thermalZoneConfig = mkMConfig "<temp>C" ["temp"]
+
+-- | Retrieves thermal information. Argument is name of thermal
+-- directory in \/sys\/clas\/thermal. Returns the monitor string
+-- parsed according to template (either default or user specified).
+runThermalZone :: [String] -> Monitor String
+runThermalZone args = do
+ let zone = head args
+ file = "/sys/class/thermal/thermal_zone" ++ zone ++ "/temp"
+ parse = return . (read :: String -> Int) . B.unpack
+ exists <- io $ fileExist file
+ if exists
+ then do mdegrees <- io $ B.readFile file >>= parse
+ temp <- showWithColors show (mdegrees `quot` 1000)
+ parseTemplate [ temp ]
+ else return "N/A"
+