summaryrefslogtreecommitdiff
path: root/.local/bin/statusbar/volume
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/statusbar/volume')
-rwxr-xr-x.local/bin/statusbar/volume91
1 files changed, 0 insertions, 91 deletions
diff --git a/.local/bin/statusbar/volume b/.local/bin/statusbar/volume
deleted file mode 100755
index f60684e..0000000
--- a/.local/bin/statusbar/volume
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/usr/bin/python3
-import subprocess
-import re
-import os
-import sys
-
-
-block = os.getenv("BLOCK_BUTTON")
-if block is not None:
- if block == '1':
- subprocess.call(["pamixer", "-t", ";", "pkill", "-RTMIN+9", "dwmblocks"])
- elif block == '3':
- subprocess.Popen([os.getenv("TERMINAL"), "-e", "pulsemixer"])
-
- quit(0)
-
-
-a = subprocess.check_output(["pactl", "list", "sinks"]).decode()
-
-SINK, PARAMS, PARAM = 0, 1, 2
-parsing = SINK
-
-re_param_str = re.compile("(.+?): (.*)")
-re_param_list = re.compile("(.+?):")
-
-current_sink = None
-current_param = None
-
-sinks = {}
-for line in a.split("\n"):
- indent = line.count("\t")
- line = line.strip()
-
- if parsing == SINK:
- if line.startswith("Sink"):
- n = line.split()[1]
- sinks[n] = {}
- current_sink = sinks[n]
-
- parsing = PARAMS
-
- elif parsing == PARAMS:
- if line == '':
- parsing = SINK
- continue
-
- match = re_param_str.match(line)
- if indent == 1 and match is not None:
- name, value = match.groups()
- current_param = name
- current_sink[name] = value
- continue
-
- match = re_param_list.match(line)
- if indent == 1 and match is not None:
- name = match.group(1)
- current_param = name
- current_sink[name] = []
- continue
-
- value = current_sink[name]
- if isinstance(value, str):
- current_sink[name] = [value]
-
- current_sink[name].append(line)
-
-percent = re.compile("(\d+)%")
-vol = None
-mute = False
-for sink in sinks.values():
- if 'JBL' in sink['Description']: # Headphones
- vol = int(percent.findall(sink['Volume'][0])[0])
- mute = sink["Mute"] == "yes"
- break
- # desktop and laptop sinks respectively
- elif 'Built-in' in sink['Description'] or 'Family 17h' in sink['Description'] and vol is None:
- vol = int(percent.findall(sink['Volume'][0])[0])
- mute = sink["Mute"] == "yes"
-
-
-format_string = "%i"
-if len(sys.argv) > 1:
- format_string = sys.argv[1]
-
-if vol is None or mute:
- vol = "Muted"
-else:
- v = vol // 10
-
-print(format_string % vol)
-