diff options
author | Toby Vincent <tobyv@tobyvin.dev> | 2024-05-16 20:07:23 -0500 |
---|---|---|
committer | Toby Vincent <tobyv@tobyvin.dev> | 2024-05-16 20:07:23 -0500 |
commit | 1bdcce448d08939af8e912d7c7cfbc77f73dcf79 (patch) | |
tree | 604b6371eb8b7b86234c1b80ec5029b787769a46 /i3blocks/.local/bin/i3blocks-dunst | |
parent | 05a5cd8d61d304d5bafec3f947ca8718cf013851 (diff) |
feat(i3blocks,wip): add i3blocks config
Diffstat (limited to 'i3blocks/.local/bin/i3blocks-dunst')
-rwxr-xr-x | i3blocks/.local/bin/i3blocks-dunst | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/i3blocks/.local/bin/i3blocks-dunst b/i3blocks/.local/bin/i3blocks-dunst new file mode 100755 index 0000000..b21042f --- /dev/null +++ b/i3blocks/.local/bin/i3blocks-dunst @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 + +import os +import subprocess + + +def muted(): + """Returns True if Dunst is muted""" + cmd = ["dunstctl", "is-paused"] + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) + output = proc.communicate()[0] + return "true" == output.strip().decode("UTF-8") + + +def notif(t): + """Returns notification count""" + cmd = ["dunstctl", "count", t] + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) + output = proc.communicate()[0] + return int(output.strip().decode("UTF-8")) + + +button = os.environ.get("BLOCK_BUTTON", None) + +if button == "1": + subprocess.run(["dunstctl", "history-pop"], check=True) +elif button == "3": + subprocess.run(["dunstctl", "set-paused", "toggle"], check=True) + + +if notif("waiting") > 0: + print("\uf1f6") +elif notif("displayed") > 0: + print("\uf0f3") +elif muted(): + print("\uf1f7") +else: + print("\uf0a2") |