Merge pull request #198 from cacyss0807/modules_modifications
Minor modules modifications
This commit is contained in:
commit
d0877ae46c
2 changed files with 8 additions and 8 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)
|
||||||
|
|
|
@ -21,7 +21,6 @@ class Module(bumblebee.engine.Module):
|
||||||
self.update_widgets(widgets)
|
self.update_widgets(widgets)
|
||||||
|
|
||||||
def update_widgets(self, widgets):
|
def update_widgets(self, widgets):
|
||||||
new_widgets = []
|
|
||||||
for line in bumblebee.util.execute("xrandr -q").split("\n"):
|
for line in bumblebee.util.execute("xrandr -q").split("\n"):
|
||||||
if not " connected" in line:
|
if not " connected" in line:
|
||||||
continue
|
continue
|
||||||
|
@ -37,16 +36,12 @@ class Module(bumblebee.engine.Module):
|
||||||
if not widget:
|
if not widget:
|
||||||
widget = bumblebee.output.Widget(full_text=display, name=display)
|
widget = bumblebee.output.Widget(full_text=display, name=display)
|
||||||
self._engine.input.register_callback(widget, button=bumblebee.input.LEFT_MOUSE, cmd=self._toggle)
|
self._engine.input.register_callback(widget, button=bumblebee.input.LEFT_MOUSE, cmd=self._toggle)
|
||||||
new_widgets.append(widget)
|
|
||||||
widget.set("orientation", orientation)
|
widget.set("orientation", orientation)
|
||||||
|
|
||||||
while len(widgets) > 0:
|
|
||||||
del widgets[0]
|
|
||||||
for widget in new_widgets:
|
|
||||||
widgets.append(widget)
|
widgets.append(widget)
|
||||||
|
|
||||||
def update(self, widgets):
|
def update(self, widgets):
|
||||||
self.update_widgets(widgets)
|
if len(widgets) <= 0:
|
||||||
|
self.update_widgets(widgets)
|
||||||
|
|
||||||
def state(self, widget):
|
def state(self, widget):
|
||||||
return widget.get("orientation", "normal")
|
return widget.get("orientation", "normal")
|
||||||
|
|
Loading…
Reference in a new issue