commit 205971bdfc454ca759714aac29c8ffc9031bae08
parent 040b621f1028e6db52917db69518767a6061c1eb
Author: hhvn <dev@hhvn.uk>
Date: Fri, 3 Dec 2021 21:17:07 +0000
.s/d/vol: draw volume icon
Diffstat:
1 file changed, 41 insertions(+), 10 deletions(-)
diff --git a/.scripts/dwmblocks/vol b/.scripts/dwmblocks/vol
@@ -2,19 +2,50 @@
# Copyright (c) 2019-2021 Hayden Hamilton.
[ "$(uname)" = "Linux" ] && {
- toggled=$(amixer sget Master | awk '/Mono/ {print $6}' | tr -d '[]')
- volume=$(amixer sget Master | awk '/Mono/ {print $4}' | tr -d '[]')
+ toggled=$(amixer sget Master | awk '/Mono/ {print $6}' | tr -d '[]\n')
+ volume=$(amixer sget Master | awk '/Mono/ {print $4}' | tr -d '[]\n')
}
[ "$(uname)" = "OpenBSD" ] && {
- toggled=$(sndioctl output.mute | sed 's/.*=//;s/0/on/;s/1/off/')
- volume=$(sndioctl output.level | sed -E 's/.*=//;s/(.)\.(..)(.)/\1\2.\3/;s/^0*//;s/\.0$//;s/$/%/')
+ toggled=$(sndioctl output.mute | sed 's/.*=//;s/0/on/;s/1/off/' | tr -d '\n')
+ volume=$(sndioctl output.level | sed -E 's/.*=//;s/(.)\.(..)(.)/\1\2.\3/;s/^0*//;s/\.0$//;s/$/%/' | tr -d '\n')
}
-colour="^c#7777cc^"
-colour2="^d^"
-echo "$toggled" | grep on >/dev/null || {
- colour="^c#555555^"
- colour2="^c#666666^"
+echo "$toggled" | grep on >/dev/null && {
+icon="
+
+
+ #
+ #### # #
+# # # # #
+# # # # #
+# # # # #
+# # # # #
+# # # # #
+ #### # #
+ #"
+} || {
+icon="
+
+
+
+ ####
+# # # #
+# # # #
+# # #
+# # # #
+# # # #
+ ####"
}
-printf '[%sVOL%s%s]' "$colour" "$colour2" "${volume}"
+printf '%s' "["
+printf '%s' "$icon" | awk '
+ BEGIN { line = 0; }
+ {
+ split($0, chars, "");
+ for (i=1; i <= length($0); i++)
+ if (chars[i] == "#")
+ printf("^r%d,%d,1,1^", i, line);
+ line++;
+ }'
+
+printf '^f14^%s]\n' "$volume"