Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sigggii committed Oct 3, 2023
2 parents 8576092 + 3bc3c75 commit 68de299
Show file tree
Hide file tree
Showing 9 changed files with 213 additions and 20 deletions.
11 changes: 8 additions & 3 deletions bumblebee_status/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,16 @@ def __init__(self, args):
: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"):
Expand Down
2 changes: 2 additions & 0 deletions bumblebee_status/modules/contrib/dunstctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def __init__(self, config, theme):
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)
Expand Down
1 change: 1 addition & 0 deletions bumblebee_status/modules/contrib/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def update(self):
# 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
Expand Down
3 changes: 2 additions & 1 deletion bumblebee_status/modules/contrib/title.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ def __init__(self, config, theme):

# 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()

Expand Down
4 changes: 2 additions & 2 deletions bumblebee_status/modules/core/pulsectl.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ def display(self, _):
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 != ""
Expand Down
14 changes: 13 additions & 1 deletion bumblebee_status/util/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions docs/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ like this:
-t <theme>
}
Line continuations (breaking a single line into multiple lines) is allowed in
the i3 configuration, but please ensure that all lines except the final one need to have a trailing
"\".
This is explained in detail here:
[i3 user guide: line continuation](https://i3wm.org/docs/userguide.html#line_continuation)



You can retrieve a list of modules (and their parameters) and themes by
entering:

Expand Down
Loading

0 comments on commit 68de299

Please sign in to comment.