Merge pull request #145 from ibrokemypie/cputemp
modules/sensors: remove sensors dependency and read from device
This commit is contained in:
commit
0fb03dfa8f
2 changed files with 5 additions and 16 deletions
|
@ -119,7 +119,6 @@ Modules and commandline utilities are only required for modules, the core itself
|
||||||
* ping (for the module 'ping')
|
* ping (for the module 'ping')
|
||||||
* redshift (for the module 'redshift')
|
* redshift (for the module 'redshift')
|
||||||
* xrandr (for the module 'xrandr')
|
* xrandr (for the module 'xrandr')
|
||||||
* sensors (for the module 'sensors')
|
|
||||||
* mpc (for the module 'mpd')
|
* mpc (for the module 'mpd')
|
||||||
* bluez / blueman (for module 'bluetooth')
|
* bluez / blueman (for module 'bluetooth')
|
||||||
* dbus-send (for module 'bluetooth')
|
* dbus-send (for module 'bluetooth')
|
||||||
|
|
|
@ -3,12 +3,8 @@
|
||||||
|
|
||||||
"""Displays sensor temperature
|
"""Displays sensor temperature
|
||||||
|
|
||||||
Requires the following executable:
|
|
||||||
* sensors
|
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
* sensors.match: Line to match against output of 'sensors -u' (default: temp1_input)
|
* sensors.path: path to temperature file (default /sys/class/thermal/thermal_zone0/temp).
|
||||||
* sensors.match_number: which of the matches you want (default -1: last match).
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
@ -23,19 +19,13 @@ class Module(bumblebee.engine.Module):
|
||||||
bumblebee.output.Widget(full_text=self.temperature))
|
bumblebee.output.Widget(full_text=self.temperature))
|
||||||
self._temperature = "unknown"
|
self._temperature = "unknown"
|
||||||
self._mhz = "n/a"
|
self._mhz = "n/a"
|
||||||
pattern = self.parameter("match", "temp1_input")
|
|
||||||
pattern_string = r"^\s*{}:\s*([\d.]+)$".format(pattern)
|
|
||||||
self._match_number = int(self.parameter("match_number", "-1"))
|
|
||||||
self._pattern = re.compile(pattern_string, re.MULTILINE)
|
|
||||||
engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE, cmd="xsensors")
|
engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE, cmd="xsensors")
|
||||||
|
|
||||||
def get_temp(self):
|
def get_temp(self):
|
||||||
temperatures = bumblebee.util.execute("sensors -u")
|
try:
|
||||||
matching_temp = self._pattern.findall(temperatures)
|
temperature = open(self.parameter("path", "/sys/class/thermal/thermal_zone0/temp")).read()[:2]
|
||||||
|
except IOError:
|
||||||
temperature = "unknown"
|
temperature = "unknown"
|
||||||
if matching_temp:
|
|
||||||
temperature = int(float(matching_temp[self._match_number]))
|
|
||||||
|
|
||||||
return temperature
|
return temperature
|
||||||
|
|
||||||
def get_mhz( self ):
|
def get_mhz( self ):
|
||||||
|
|
Loading…
Reference in a new issue