added format parameter to cpu module
This commit is contained in:
parent
a84e568746
commit
28ee0b474d
1 changed files with 6 additions and 1 deletions
|
@ -5,6 +5,7 @@
|
||||||
Parameters:
|
Parameters:
|
||||||
* cpu.warning : Warning threshold in % of CPU usage (defaults to 70%)
|
* cpu.warning : Warning threshold in % of CPU usage (defaults to 70%)
|
||||||
* cpu.critical: Critical threshold in % of CPU usage (defaults to 80%)
|
* cpu.critical: Critical threshold in % of CPU usage (defaults to 80%)
|
||||||
|
* cpu.format : Format string (defaults to "{:.01f}%)")
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -25,8 +26,12 @@ class Module(bumblebee.engine.Module):
|
||||||
engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE,
|
engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE,
|
||||||
cmd="gnome-system-monitor")
|
cmd="gnome-system-monitor")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _format(self):
|
||||||
|
return self.parameter("format", "{:.01f}%")
|
||||||
|
|
||||||
def utilization(self, _):
|
def utilization(self, _):
|
||||||
return "{:.01f}%".format(self._utilization)
|
return self._format.format(self._utilization)
|
||||||
|
|
||||||
def update(self, widgets):
|
def update(self, widgets):
|
||||||
self._utilization = psutil.cpu_percent(percpu=False)
|
self._utilization = psutil.cpu_percent(percpu=False)
|
||||||
|
|
Loading…
Reference in a new issue