Merge branch 'master' of git://github.com/tobi-wan-kenobi/bumblebee-status

This commit is contained in:
Lucas Souto 2018-09-07 22:22:07 -03:00
commit 17131c5bdc
8 changed files with 122 additions and 22 deletions

View file

@ -35,6 +35,8 @@ class Module(bumblebee.engine.Module):
self._states["include"].append(state)
self._format = self.parameter("format","{intf} {state} {ip} {ssid}");
self._update_widgets(widgets)
self.iwgetid = bumblebee.util.which("iwgetid")
def update(self, widgets):
self._update_widgets(widgets)
@ -106,7 +108,7 @@ class Module(bumblebee.engine.Module):
def get_ssid(self, intf):
if self._iswlan(intf):
try:
return subprocess.check_output(["iwgetid","-r",intf]).strip().decode('utf-8')
return subprocess.check_output([self.iwgetid,"-r",intf]).strip().decode('utf-8')
except:
return ""
return ""

View file

@ -0,0 +1,51 @@
# pylint: disable=C0111,R0903
"""Displays the result of a notmuch count query
default : unread emails which path do not contained "Trash" (notmuch count "tag:unread AND NOT path:/.*Trash.*/")
Parameters:
* notmuch_count.query: notmuch count query to show result
Errors:
if the notmuch query failed, the shown value is -1
Dependencies:
notmuch (https://notmuchmail.org/)
"""
import bumblebee.input
import bumblebee.output
import bumblebee.engine
import os
class Module(bumblebee.engine.Module):
def __init__(self, engine, config):
super(Module, self).__init__(engine, config,
bumblebee.output.Widget(full_text=self.output)
)
self._notmuch_count_query = self.parameter("query", "tag:unread AND NOT path:/.*Trash.*/")
self._notmuch_count = self.count_notmuch()
def output(self, widget):
self._notmuch_count = self.count_notmuch()
return str(self._notmuch_count)
def state(self, widgets):
if self._notmuch_count == 0:
return "empty"
return "items"
def count_notmuch(self):
try:
notmuch_count_cmd = "notmuch count " + self._notmuch_count_query
notmuch_count = int(bumblebee.util.execute(notmuch_count_cmd))
return notmuch_count
except Exception:
return -1
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4

View file

@ -6,6 +6,7 @@ Aliases: pasink (use this to control output instead of input), pasource
Parameters:
* pulseaudio.autostart: If set to "true" (default is "false"), automatically starts the pulseaudio daemon if it is not running
* pulseaudio.percent_change: How much to change volume by when scrolling on the module (default is 2%)
Requires the following executable:
* pulseaudio
@ -33,6 +34,13 @@ class Module(bumblebee.engine.Module):
bumblebee.util.execute("pulseaudio --start")
except Exception:
pass
try:
percent_change = int(self.parameter("percent_change","2%").strip("%"))
except:
percent_change = 2
if percent_change < 0 or percent_change > 100:
percent_change = 2
self._left = 0
self._right = 0
@ -51,8 +59,8 @@ class Module(bumblebee.engine.Module):
events = [
{"type": "mute", "action": "toggle", "button": bumblebee.input.LEFT_MOUSE},
{"type": "volume", "action": "+2%", "button": bumblebee.input.WHEEL_UP},
{"type": "volume", "action": "-2%", "button": bumblebee.input.WHEEL_DOWN},
{"type": "volume", "action": "+{percent}%".format(percent=percent_change), "button": bumblebee.input.WHEEL_UP},
{"type": "volume", "action": "-{percent}%".format(percent=percent_change), "button": bumblebee.input.WHEEL_DOWN},
]
for event in events:

View file

@ -60,4 +60,23 @@ def durationfmt(duration, shorten=False, suffix=False):
return "{}{}".format(res, suf if suffix else "")
def which(program):
import os
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
localPATH = os.environ["PATH"].split(os.pathsep)
localPATH += ["/sbin", "/usr/sbin/", "/usr/local/sbin"]
for path in localPATH:
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4