From b815b8dc30a9632e159bf4347d615b067503215f Mon Sep 17 00:00:00 2001 From: Andrew Guschin Date: Mon, 15 Nov 2021 15:31:17 +0400 Subject: Removed unneeded scripts --- .local/bin/lemonbar/modules/battery.py | 14 ----- .local/bin/lemonbar/modules/clock.py | 6 --- .local/bin/lemonbar/modules/language.py | 13 ----- .local/bin/lemonbar/modules/updates.py | 48 ----------------- .local/bin/lemonbar/modules/volume.py | 93 --------------------------------- 5 files changed, 174 deletions(-) delete mode 100644 .local/bin/lemonbar/modules/battery.py delete mode 100644 .local/bin/lemonbar/modules/clock.py delete mode 100644 .local/bin/lemonbar/modules/language.py delete mode 100644 .local/bin/lemonbar/modules/updates.py delete mode 100644 .local/bin/lemonbar/modules/volume.py (limited to '.local/bin/lemonbar/modules') diff --git a/.local/bin/lemonbar/modules/battery.py b/.local/bin/lemonbar/modules/battery.py deleted file mode 100644 index 7cf3c54..0000000 --- a/.local/bin/lemonbar/modules/battery.py +++ /dev/null @@ -1,14 +0,0 @@ -def read_file(filename): - with open(filename) as f: - return f.read().strip() - -def callback(): - battery = "BAT0" - try: - now = int(read_file(f"/sys/class/power_supply/{battery}/energy_now")) - full = int(read_file(f"/sys/class/power_supply/{battery}/energy_full")) - percent = round(now / full * 100) - return f"BAT: {percent}%" - except FileNotFoundError: - return f"BAT: Disabled" - diff --git a/.local/bin/lemonbar/modules/clock.py b/.local/bin/lemonbar/modules/clock.py deleted file mode 100644 index c4dc713..0000000 --- a/.local/bin/lemonbar/modules/clock.py +++ /dev/null @@ -1,6 +0,0 @@ -from time import strftime - - -def callback(): - clock = strftime("%d %b (%a) %H:%M") - return f"CLK: {clock}" diff --git a/.local/bin/lemonbar/modules/language.py b/.local/bin/lemonbar/modules/language.py deleted file mode 100644 index 014bf10..0000000 --- a/.local/bin/lemonbar/modules/language.py +++ /dev/null @@ -1,13 +0,0 @@ -from subprocess import run as _run - - -def run(command): - return _run(command.split(), capture_output=True).stdout.decode().strip() - - -def callback(): - try: - name = run('xkblayout-state print "%s"').strip('"') - return f"LNG: {name.upper()}" - except FileNotFoundError: - return f"LNG: xkblayout-state not installed" diff --git a/.local/bin/lemonbar/modules/updates.py b/.local/bin/lemonbar/modules/updates.py deleted file mode 100644 index 67c8e93..0000000 --- a/.local/bin/lemonbar/modules/updates.py +++ /dev/null @@ -1,48 +0,0 @@ -from subprocess import run as _run -from time import time - - -def run(command): - return _run(command.split(), capture_output=True).stdout.decode().strip() - - -def pacman_count(): - cnt = 0 - for line in run('pacman -Qu').split("\n"): - if "[ignored]" not in line: - cnt += 1 - return cnt - - -def yay_count(): - cnt = 0 - for line in run('yay -Qau').split("\n"): - if "[ignored]" not in line: - cnt += 1 - return cnt - - -def callback(): - tmp_file = "/tmp/lemonbar/updates" - try: - with open(tmp_file) as f: - data = f.read().split() - except FileNotFoundError: - data = '' - - try: - timestamp = float(data[0]) - except (ValueError, IndexError): - timestamp = 0 - - if time() - timestamp > 900: - pacman = pacman_count() - aur = yay_count() - with open(tmp_file, "w") as f: - f.write(f"{time()} {pacman} {aur}") - else: - pacman = data[1] - aur = data[2] - - return f"UPD: {pacman}+{aur}" - diff --git a/.local/bin/lemonbar/modules/volume.py b/.local/bin/lemonbar/modules/volume.py deleted file mode 100644 index f911571..0000000 --- a/.local/bin/lemonbar/modules/volume.py +++ /dev/null @@ -1,93 +0,0 @@ -from subprocess import run as _run -import re - - -def run(command): - return _run(command.split(), capture_output=True).stdout.decode().strip() - - -def get_default_sink(): - default_name = None - for line in run("pactl info").split("\n"): - key, val = line.split(": ") - if key == "Default Sink": - default_name = val - break - - if default_name is None: - return None - - for sid, sink in get_sinks().items(): - if sink["Name"] == default_name: - return sink - return None - - -def get_sinks(): - 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 run("pactl list sinks").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) - - return sinks - - -def get_sink_volume(sink): - if sink is None: - return "None" - if sink["Mute"] == "yes": - return "Muted" - - match = re.search(r"(\d+?)%", sink["Volume"][0]) - if match is not None: - return f"{match.groups()[0]}%" - - -def callback(): - def_sink = get_default_sink() - vol = get_sink_volume(def_sink) - - return f"VOL: {vol}" - -- cgit v1.2.3