summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Guschin <saintruler@gmail.com>2021-11-15 15:31:17 +0400
committerAndrew Guschin <saintruler@gmail.com>2021-11-15 15:31:17 +0400
commitb815b8dc30a9632e159bf4347d615b067503215f (patch)
treeb6ea0d48d364ccd7c7341576711112fa156c9f84
parent54d45cc3ddc50fb0db021aca14ea9284c7937984 (diff)
Removed unneeded scripts
-rw-r--r--.local/bin/lemonbar/bargen.py73
-rw-r--r--.local/bin/lemonbar/bspc.py55
-rw-r--r--.local/bin/lemonbar/chain.py59
-rw-r--r--.local/bin/lemonbar/kill_lemonbar.sh6
-rw-r--r--.local/bin/lemonbar/modules/battery.py14
-rw-r--r--.local/bin/lemonbar/modules/clock.py6
-rw-r--r--.local/bin/lemonbar/modules/language.py13
-rw-r--r--.local/bin/lemonbar/modules/updates.py48
-rw-r--r--.local/bin/lemonbar/modules/volume.py93
-rw-r--r--.local/bin/lemonbar/run_lemonbar.sh16
-rwxr-xr-x.local/bin/scripts/getrange32
-rwxr-xr-x.local/bin/scripts/shellprompt3
-rwxr-xr-x.local/bin/scripts/syncmail6
-rwxr-xr-x.local/bin/statusbar/battery42
-rwxr-xr-x.local/bin/statusbar/clock4
-rwxr-xr-x.local/bin/statusbar/disk12
-rwxr-xr-x.local/bin/statusbar/pacpackages10
-rwxr-xr-x.local/bin/statusbar/popupgrade14
-rwxr-xr-x.local/bin/statusbar/volume91
19 files changed, 0 insertions, 597 deletions
diff --git a/.local/bin/lemonbar/bargen.py b/.local/bin/lemonbar/bargen.py
deleted file mode 100644
index a4088d3..0000000
--- a/.local/bin/lemonbar/bargen.py
+++ /dev/null
@@ -1,73 +0,0 @@
-from chain import ArrowModuleChain
-from modules import volume, battery, updates, language, clock
-import bspc
-
-
-def get_desktops_bar():
- bar = []
- focused_bg = idle_fg = urgent_fg = occupied_fg = "#ebdbb2"
- focused_fg = idle_bg = "#282828"
- urgent_bg = "#cc241d"
- occupied_bg = "#928374"
-
- for i, desktop in enumerate(bspc.get_desktops(), 1):
- if desktop.focused:
- fg = focused_fg
- bg = focused_bg
- elif desktop.urgent:
- fg = urgent_fg
- bg = urgent_bg
- elif desktop.occupied:
- fg = occupied_fg
- bg = occupied_bg
- else:
- fg = idle_fg
- bg = idle_bg
-
- bar.append({
- "callback": lambda idx=i: str(idx),
- "foreground": fg,
- "background": bg,
- })
-
- return bar
-
-
-status_modules = [
- {
- "callback": updates.callback,
- "foreground": "#ebdbb2",
- "background": "#689d6a",
- },
- {
- "callback": volume.callback,
- "foreground": "#ebdbb2",
- "background": "#458588",
- },
- {
- "callback": battery.callback,
- "foreground": "#ebdbb2",
- "background": "#b16286",
- },
- {
- "callback": language.callback,
- "foreground": "#ebdbb2",
- "background": "#98971a",
- },
- {
- "callback": clock.callback,
- "foreground": "#ebdbb2",
- "background": "#cc241d",
- },
-]
-
-desktops = ArrowModuleChain(right=True, capped_left=True, capped_right=False)
-desktops.extend(*get_desktops_bar())
-
-focused_window = bspc.get_focused_window_name()
-
-status = ArrowModuleChain(right=False, capped_left=False, capped_right=True)
-status.extend(*status_modules)
-
-print(f"%{{l}}{desktops} %{{F#ebdbb2}}{focused_window} %{{r}}{status}%{{B#000000}}")
-
diff --git a/.local/bin/lemonbar/bspc.py b/.local/bin/lemonbar/bspc.py
deleted file mode 100644
index f681485..0000000
--- a/.local/bin/lemonbar/bspc.py
+++ /dev/null
@@ -1,55 +0,0 @@
-from subprocess import run as _run
-
-
-class Desktop:
- def __init__(self):
- self.id = None
- self.name = None
- self.focused = False
- self.occupied = False
- self.urgent = False
-
-
-def run(command):
- return _run(command.split(), capture_output=True).stdout.decode().strip()
-
-
-def get_desktops():
- focused = run("bspc query -D -d .focused")
- occupied = run("bspc query -D -d .occupied").split("\n")
- urgent = run("bspc query -D -d .urgent").split("\n")
-
- desktops = []
- for desktop_id in run("bspc query -D").split("\n"):
- desktop = Desktop()
- desktop.id = desktop_id
- desktop.name = run(f"bspc query -D -d {desktop.id} --names")
- desktop.focused = desktop.id == focused
- desktop.occupied = desktop.id in occupied
- desktop.urgent = desktop.id in urgent
-
- desktops.append(desktop)
-
- return desktops
-
-
-def cut_name(name):
- if len(name) > 70:
- return name[:65] + "..."
- else:
- return name
-
-
-def get_focused_window_name():
- focused = run("bspc query -N -n")
- if len(focused) == 0:
- return ''
- else:
- focused = focused.lower()
-
- for window in run("wmctrl -l").split("\n"):
- wid, _, _, name = window.split(maxsplit=3)
- if wid.lower() == focused:
- return cut_name(name)
- return ''
-
diff --git a/.local/bin/lemonbar/chain.py b/.local/bin/lemonbar/chain.py
deleted file mode 100644
index c825501..0000000
--- a/.local/bin/lemonbar/chain.py
+++ /dev/null
@@ -1,59 +0,0 @@
-class ArrowModuleChain:
- def __init__(self, right, background="#000000", capped_left=False, capped_right=False):
- self.sep = "\uE0B0" if right else "\uE0B2"
-
- self.bg = background
- self.right = right
-
- self.chain = []
- self.modules = []
-
- self.capped_left = capped_left
- self.capped_right = capped_right
-
- def append(self, module):
- if len(self.modules) > 0:
- self.chain.pop()
- fg = module["background"]
- bg = self.modules[-1]["background"]
- else:
- bg = module["background"] if self.capped_left else self.bg
- fg = module["background"]
-
- if not self.right:
- bg, fg = fg, bg
- self.chain.append(self.get_sep(bg, fg))
-
- bg = module["background"] if self.capped_right else self.bg
- fg = module["background"]
-
- if not self.right:
- bg, fg = fg, bg
-
- self.chain.append(self.get_sep(fg, bg))
-
- self.modules.append(module)
-
- def extend(self, *modules):
- for module in modules:
- self.append(module)
-
- def get_sep(self, fg, bg):
- return f"%{{F{fg}}}%{{B{bg}}}{self.sep}"
-
- def __str__(self):
- result = []
- for i in range(len(self.modules)):
- result.append(self.chain[i])
-
- bg = self.modules[i]["background"]
- fg = self.modules[i]["foreground"]
- text = self.modules[i]["callback"]()
- text = f"%{{F{fg}}}%{{B{bg}}} {text} "
- result.append(text)
-
- if len(self.chain) > 0:
- result.append(self.chain[-1])
-
- return "".join(result)
-
diff --git a/.local/bin/lemonbar/kill_lemonbar.sh b/.local/bin/lemonbar/kill_lemonbar.sh
deleted file mode 100644
index fc08068..0000000
--- a/.local/bin/lemonbar/kill_lemonbar.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-pids=$(pgrep -f "sh .*run_lemonbar")
-for pid in $pids ; do
- kill $pid
-done
-pid=$(pgrep "lemonbar")
-kill $pid
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}"
-
diff --git a/.local/bin/lemonbar/run_lemonbar.sh b/.local/bin/lemonbar/run_lemonbar.sh
deleted file mode 100644
index 1e5f967..0000000
--- a/.local/bin/lemonbar/run_lemonbar.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-basedir=$(dirname $0)
-cd $basedir
-
-fontsize="16"
-font="DejaVu Sans Mono:style=Bold,size=${fontsize}"
-# powerline-fonts-git aur package
-iconsfont="xos4 Terminess Powerline:size=${fontsize}"
-
-rm -rf /tmp/lemonbar
-mkdir /tmp/lemonbar
-while :; do
- printf "%s\n" "$(python3 bargen.py)"
- sleep 0.5
-done | lemonbar -f "${font}" -f "${iconsfont}" -p
-
-wait
diff --git a/.local/bin/scripts/getrange b/.local/bin/scripts/getrange
deleted file mode 100755
index 561dfdc..0000000
--- a/.local/bin/scripts/getrange
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/sbin/python3
-import sys
-def nempty(l):
- return [i for i in l if i]
-
-
-if len(sys.argv) > 2:
- s = sys.argv[2]
-else:
- s = input()
-
-l = nempty(s.strip().split())
-r = sys.argv[1].split(":")
-
-if len(r) == 3:
- start, end, step = map(int, r)
-elif len(r) == 2:
- if r[0] == '':
- start = 0
- end = int(r[1])
- step = 1
- elif r[1] == '':
- start = int(r[0])
- end = len(l)
- step = 1
- else:
- start, end = r
- step = 1
-
-print(' '.join(l[start:end:step]))
-
-
diff --git a/.local/bin/scripts/shellprompt b/.local/bin/scripts/shellprompt
deleted file mode 100755
index 80b045f..0000000
--- a/.local/bin/scripts/shellprompt
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-read -p "$1 [yN] " ans
-([[ "$ans" == "Y" || "$ans" == "y" ]] && exit 0) || exit 1
diff --git a/.local/bin/scripts/syncmail b/.local/bin/scripts/syncmail
deleted file mode 100755
index 1402568..0000000
--- a/.local/bin/scripts/syncmail
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh
-
-notify-send -a "syncmail" "Syncing started"
-mbsync -a -c "$XDG_CONFIG_HOME/isync/mbsyncrc"
-mailcnt=$(ls ~/mail/gmail/Inbox/new/ | wc -l)
-notify-send -a "syncmail" "Syncing complete" "Got $mailcnt new e-mails"
diff --git a/.local/bin/statusbar/battery b/.local/bin/statusbar/battery
deleted file mode 100755
index dfdc39c..0000000
--- a/.local/bin/statusbar/battery
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/bin/sh
-for battery in /sys/class/power_supply/BAT?
-do
- # Get its remaining capacity and charge status.
- capacity=$(cat "$battery"/capacity) || break
- status=$(sed "s/[Dd]ischarging/discharging/;s/[Nn]ot charging/not_charging/;s/[Cc]harging/charging/;s/[Uu]nknown/unknown/;s/[Ff]ull/full/" "$battery"/status)
-
- if [ "$status" = "charging" ]; then
- if [ "$capacity" -le 20 ]; then
- icon=""
- elif [ "$capacity" -le 40 ]; then
- icon=""
- elif [ "$capacity" -le 60 ]; then
- icon=""
- elif [ "$capacity" -le 80 ]; then
- icon=""
- elif [ "$capacity" -lt 95 ]; then
- icon=""
- elif [ "$capacity" -le 100 ]; then
- icon=""
- fi
- elif [ "$status" = "discharging" ]; then
- if [ "$capacity" -le 20 ]; then
- icon=""
- elif [ "$capacity" -le 40 ]; then
- icon=""
- elif [ "$capacity" -le 60 ]; then
- icon=""
- elif [ "$capacity" -le 80 ]; then
- icon=""
- elif [ "$capacity" -lt 95 ]; then
- icon=""
- elif [ "$capacity" -le 100 ]; then
- icon=""
- fi
- elif [ "$status" = "full" ]; then
- icon=""
- fi
-
- # printf "%s %s%% " "$icon" "$capacity"
- printf "Battery: %s%%" "$capacity"
-done | sed 's/ *$//'
diff --git a/.local/bin/statusbar/clock b/.local/bin/statusbar/clock
deleted file mode 100755
index d5e3685..0000000
--- a/.local/bin/statusbar/clock
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-d=$(date "+%d %b (%a) %k:%M")
-printf " ${d}"
diff --git a/.local/bin/statusbar/disk b/.local/bin/statusbar/disk
deleted file mode 100755
index 73bc07c..0000000
--- a/.local/bin/statusbar/disk
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-
-getDiskSpace () {
- echo $(df -h | grep "$1$" | awk '{ print $3 "/" $2 }')
-}
-
-case $BLOCK_BUTTON in
- 1) setsid -f "$TERMINAL" -e ncdu "/home/$USER" ;;
-esac
-
-host=$(hostname -s)
-echo " /home: $(getDiskSpace "/home")"
diff --git a/.local/bin/statusbar/pacpackages b/.local/bin/statusbar/pacpackages
deleted file mode 100755
index 618ec2a..0000000
--- a/.local/bin/statusbar/pacpackages
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh
-
-case $BLOCK_BUTTON in
- 1) setsid -f "$TERMINAL" -e popupgrade ;;
-esac
-
-pacmancnt=$(pacman -Qu | grep -Fcv "[ignored]")
-aurcnt=$(yay -Qau | grep -Fcv "[ignored]")
-echo "$pacmancnt+$aurcnt" | sed "s/^/Packages: /"
-
diff --git a/.local/bin/statusbar/popupgrade b/.local/bin/statusbar/popupgrade
deleted file mode 100755
index 9d62b31..0000000
--- a/.local/bin/statusbar/popupgrade
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/sh
-
-printf "Packages to upgrade:\\n"
-pacman -Qu
-sudo pacman -Syu
-pkill -RTMIN+3 "${STATUSBAR:-dwmblocks}"
-
-printf "\\nAUR packages to upgrade:\\n"
-yay -Qau
-shellprompt "Upgrade AUR packages?" && yay -Sau
-pkill -RTMIN+3 "${STATUSBAR:-dwmblocks}"
-
-printf "\\nUpgrade complete.\\nPress <Enter> to exit window.\\n\\n"
-read -r
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)
-