blob: b21042f9efa41ac313a4423b980f972ba853096a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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")
|