Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
68de299763
9 changed files with 213 additions and 20 deletions
|
@ -240,11 +240,16 @@ class Config(util.store.Store):
|
|||
:param filename: path to the file to load
|
||||
"""
|
||||
|
||||
def load_config(self, filename):
|
||||
if os.path.exists(filename):
|
||||
def load_config(self, filename, content=None):
|
||||
if os.path.exists(filename) or content != None:
|
||||
log.info("loading {}".format(filename))
|
||||
tmp = RawConfigParser()
|
||||
tmp.read(u"{}".format(filename))
|
||||
tmp.optionxform = str
|
||||
|
||||
if content:
|
||||
tmp.read_string(content)
|
||||
else:
|
||||
tmp.read(u"{}".format(filename))
|
||||
|
||||
if tmp.has_section("module-parameters"):
|
||||
for key, value in tmp.items("module-parameters"):
|
||||
|
|
|
@ -28,6 +28,8 @@ class Module(core.module.Module):
|
|||
self.__states = {"unknown": ["unknown", "critical"],
|
||||
"true": ["muted", "warning"],
|
||||
"false": ["unmuted"]}
|
||||
if util.format.asbool(self.parameter("disabled", False)):
|
||||
util.cli.execute("dunstctl set-paused true", ignore_errors=True)
|
||||
|
||||
def toggle_state(self, event):
|
||||
util.cli.execute("dunstctl set-paused toggle", ignore_errors=True)
|
||||
|
|
|
@ -61,6 +61,7 @@ class Module(core.module.Module):
|
|||
# if requested then run not async version and just execute command in this thread
|
||||
if not self.__async:
|
||||
self.__output = util.cli.execute(self.__command, shell=True, ignore_errors=True).strip()
|
||||
core.event.trigger("update", [self.id], redraw_only=True)
|
||||
return
|
||||
|
||||
# if previous thread didn't end yet then don't do anything
|
||||
|
|
|
@ -50,8 +50,9 @@ class Module(core.module.Module):
|
|||
|
||||
# create a connection with i3ipc
|
||||
self.__i3 = i3ipc.Connection()
|
||||
# event is called both on focus change and title change
|
||||
# event is called both on focus change and title change, and on workspace change
|
||||
self.__i3.on("window", lambda __p_i3, __p_e: self.__pollTitle())
|
||||
self.__i3.on("workspace", lambda __p_i3, __p_e: self.__pollTitle())
|
||||
# begin listening for events
|
||||
threading.Thread(target=self.__i3.main).start()
|
||||
|
||||
|
|
|
@ -110,8 +110,8 @@ class Module(core.module.Module):
|
|||
res = f"{res} {util.graph.hbar(self.__volume*100)}"
|
||||
|
||||
if self.__show_device_name:
|
||||
friendly_name = self.parameter(self.__devicename.lower(), self.__devicename)
|
||||
icon = self.parameter("icon." + self.__devicename.lower(), "")
|
||||
friendly_name = self.parameter(self.__devicename, self.__devicename)
|
||||
icon = self.parameter("icon." + self.__devicename, "")
|
||||
res = (
|
||||
icon + " " + friendly_name + " | " + res
|
||||
if icon != ""
|
||||
|
|
|
@ -52,7 +52,19 @@ def execute(
|
|||
raise RuntimeError("{} not found".format(cmd))
|
||||
|
||||
if wait:
|
||||
out, _ = proc.communicate()
|
||||
timeout = 60
|
||||
try:
|
||||
out, _ = proc.communicate(timeout=timeout)
|
||||
except subprocess.TimeoutExpired as e:
|
||||
logging.warning(
|
||||
f"""
|
||||
Communication with process pid={proc.pid} hangs for more
|
||||
than {timeout} seconds.
|
||||
If this is not expected, the process is stale, or
|
||||
you might have run in stdout / stderr deadlock.
|
||||
"""
|
||||
)
|
||||
out, _ = proc.communicate()
|
||||
if proc.returncode != 0:
|
||||
err = "{} exited with code {}".format(cmd, proc.returncode)
|
||||
logging.warning(err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue