Possible "fix" for #69

This commit is contained in:
enkore 2014-06-13 20:25:28 +02:00
parent 33dc5d0185
commit 8f0ac4bdb6
3 changed files with 12 additions and 32 deletions

View File

@ -76,6 +76,8 @@ next
audio is muted.
* `parcel`_: added support for Itella (Finnish national postal service)
* `network`_: detached_down is now True by default
* `temp`_: removed color_critical and high_factor options
* `temp`_: fixed issue with Linux kernels 3.15 and newer
3.29
++++
@ -692,7 +694,7 @@ Settings:
:host: (default: ``localhost``)
:port: MPD port (default: ``6600``)
:format: formatp string (default: ``{title} {status}``)
:status: Dictionary mapping pause, play and stop to output (default: ``{'play': '▶', 'pause': '▷', 'stop': '◾'}``)
:status: Dictionary mapping pause, play and stop to output (default: ``{'play': '▶', 'stop': '◾', 'pause': '▷'}``)
:interval: (default: ``1``)
@ -884,10 +886,8 @@ AMD is currently not supported as they can only report a relative temperature, w
Settings:
:format: format string used for output. {temp} is the temperature in degrees celsius, {critical} and {high} are the trip point temps. (default: ``{temp} °C``)
:format: format string used for output. {temp} is the temperature in degrees celsius (default: ``{temp} °C``)
:color: (default: ``#FFFFFF``)
:color_critical: (default: ``#FF0000``)
:high_factor: (default: ``0.7``)
:interval: (default: ``5``)

View File

@ -76,6 +76,8 @@ next
audio is muted.
* `parcel`_: added support for Itella (Finnish national postal service)
* `network`_: detached_down is now True by default
* `temp`_: removed color_critical and high_factor options
* `temp`_: fixed issue with Linux kernels 3.15 and newer
3.29
++++

View File

@ -13,42 +13,20 @@ class Temperature(IntervalModule):
settings = (
("format",
"format string used for output. {temp} is the temperature in degrees celsius, {critical} and {high} are the trip point temps."),
"color", "color_critical", "high_factor"
"format string used for output. {temp} is the temperature in degrees celsius"),
"color",
)
format = "{temp} °C"
high_factor = 0.7
color = "#FFFFFF"
color_high = "#FFFF00"
color_critical = "#FF0000"
def init(self):
self.base_path = "/sys/devices/platform/coretemp.0"
input = glob.glob(
"{base_path}/temp*_input".format(base_path=self.base_path))[0]
self.input = re.search("temp([0-9]+)_input", input).group(1)
self.base_path = "{base_path}/temp{input}_".format(
base_path=self.base_path, input=self.input)
with open("{base_path}crit".format(base_path=self.base_path), "r") as f:
self.critical = float(f.read().strip()) / 1000
self.high = self.critical * self.high_factor
self.file = "/sys/class/thermal/thermal_zone0/temp"
def run(self):
with open("{base_path}input".format(base_path=self.base_path), "r") as f:
with open(self.file, "r") as f:
temp = float(f.read().strip()) / 1000
urgent = False
color = self.color
if temp >= self.critical:
urgent = True
color = self.color_critical
elif temp >= self.high:
urgent = True
color = self.color_high
self.output = {
"full_text": self.format.format(temp=temp, critical=self.critical, high=self.high),
"urgent": urgent,
"color": color,
"full_text": self.format.format(temp=temp),
"color": self.color,
}