summaryrefslogtreecommitdiff
path: root/.local
diff options
context:
space:
mode:
authorAndrew <saintruler@gmail.com>2020-06-05 17:02:06 +0400
committerAndrew <saintruler@gmail.com>2020-06-05 17:02:06 +0400
commitea8ff6d7638cdd1f36cc978f1734759158b969b0 (patch)
tree18893c91594a2d58bb6757f592a076c5496e300e /.local
Initial commit
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/scripts/shellprompt3
-rwxr-xr-x.local/bin/statusbar/clock3
-rwxr-xr-x.local/bin/statusbar/disk11
-rwxr-xr-x.local/bin/statusbar/pacpackages10
-rwxr-xr-x.local/bin/statusbar/popupgrade14
-rwxr-xr-x.local/bin/statusbar/volume90
6 files changed, 131 insertions, 0 deletions
diff --git a/.local/bin/scripts/shellprompt b/.local/bin/scripts/shellprompt
new file mode 100755
index 0000000..80b045f
--- /dev/null
+++ b/.local/bin/scripts/shellprompt
@@ -0,0 +1,3 @@
+#!/bin/sh
+read -p "$1 [yN] " ans
+([[ "$ans" == "Y" || "$ans" == "y" ]] && exit 0) || exit 1
diff --git a/.local/bin/statusbar/clock b/.local/bin/statusbar/clock
new file mode 100755
index 0000000..102929e
--- /dev/null
+++ b/.local/bin/statusbar/clock
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+date "+%d %b (%a) %k:%M"
diff --git a/.local/bin/statusbar/disk b/.local/bin/statusbar/disk
new file mode 100755
index 0000000..7d6b84d
--- /dev/null
+++ b/.local/bin/statusbar/disk
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+getDiskSpace () {
+ echo $(df -h | grep "$1$" | awk '{ print $4 }')
+}
+
+case $BLOCK_BUTTON in
+ 1) setsid -f "$TERMINAL" -e ncdu '/home/andrew' ;;
+esac
+
+echo "💽$(getDiskSpace "/home")"
diff --git a/.local/bin/statusbar/pacpackages b/.local/bin/statusbar/pacpackages
new file mode 100755
index 0000000..2fafe61
--- /dev/null
+++ b/.local/bin/statusbar/pacpackages
@@ -0,0 +1,10 @@
+#!/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/^/📦/g"
+
diff --git a/.local/bin/statusbar/popupgrade b/.local/bin/statusbar/popupgrade
new file mode 100755
index 0000000..9d62b31
--- /dev/null
+++ b/.local/bin/statusbar/popupgrade
@@ -0,0 +1,14 @@
+#!/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
new file mode 100755
index 0000000..673e591
--- /dev/null
+++ b/.local/bin/statusbar/volume
@@ -0,0 +1,90 @@
+#!/sbin/python3
+import subprocess
+import re
+import os
+
+
+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']:
+ vol = int(percent.findall(sink['Volume'][0])[0])
+ mute = sink["Mute"] == "yes"
+ break
+ elif 'Built-in' in sink['Description'] and vol is None:
+ vol = int(percent.findall(sink['Volume'][0])[0])
+ mute = sink["Mute"] == "yes"
+
+
+
+if vol is None or mute:
+ print("🔇")
+
+if vol > 70:
+ icon = "🔊"
+elif vol < 30:
+ icon = "🔈"
+else:
+ icon = "🔉"
+
+print(f"{icon}{vol}%")