commit 428fbcdce10441d85a391202d779bcf8d0ec9614
parent 40b7ded6834c148cdb3fe5b835371f8ba4cfce07
Author: Alex Balgavy <alexander.balgavy@spaceapplications.com>
Date: Fri, 22 Dec 2023 23:54:16 +0100
Update dwmblock scripts
Diffstat:
4 files changed, 66 insertions(+), 14 deletions(-)
diff --git a/scripts/dwmblock-battery b/scripts/dwmblock-battery
@@ -15,6 +15,6 @@ status="$(battery | tac | tr -d '\n' | sed '
case "$status" in
âŧ*) notify "Battery low" "$status%" battery critical;;
- â
*) notify "Battery charged" "$status%" battery;;
+ # â
*) notify "Battery charged" "$status%" battery;;
esac
printf "%s%%\n" "$status"
diff --git a/scripts/dwmblock-bluetooth b/scripts/dwmblock-bluetooth
@@ -1,12 +1,6 @@
#!/bin/sh
# dwmblocks script for bluetooth
-# Interfaces:
-# (list with `nmcli --get-values GENERAL.DEVICE,GENERAL.TYPE device show`)
-wired=enp0s31f6
-wireless=wlp0s20f3
-# there's probably a way to change these but I'd have to know all files to update...
-
case "$BUTTON" in
1)
pgrep -f nmtui || "$TERMINAL" -e bluetoothctl
@@ -22,12 +16,24 @@ case "$BUTTON" in
esac
bt="$(bluetoothctl show)"
-if bluetoothctl devices | cut -f2 -d' ' | while read uuid; do bluetoothctl info $uuid; done | grep '^\s*Connected: yes' >/dev/null 2>&1; then
- printf 'ī đ'
-elif [ "$bt" = "No default controller available" ]; then
- printf "ī đ"
+res=""
+if [ "$bt" = "No default controller available" ]; then
+ res="ī đ"
elif printf '%s' "$bt" | grep '^\s*Powered: no' >/dev/null 2>&1; then
- printf 'ī â'
+ res='ī â'
elif printf '%s' "$bt" | grep '^\s*Powered: yes' >/dev/null 2>&1; then
- printf 'ī'
+ res='ī'
+ while read -r uuid; do
+ info="$(bluetoothctl info "$uuid")"
+ if printf '%s' "$info" | grep '^\s*Connected: yes' >/dev/null 2>&1; then
+ res="$res $(printf '%s' "$info" | awk -F': ' '
+ /Icon: audio-headset/ { printf "đ§ " }
+ /Icon: audio-card/ { printf "đĸ" }
+ /Battery Percentage/ { split($2, a, "[ ()]*"); printf a[2]"%" }
+ ')"
+ fi
+ done <<EOF
+ $(bluetoothctl devices | cut -f2 -d' ')
+EOF
fi
+printf '%s' "$res"
diff --git a/scripts/dwmblock-internet b/scripts/dwmblock-internet
@@ -28,7 +28,7 @@ case "$(cat /sys/class/net/$wireless/operstate 2>/dev/null)" in
else
wifiicon="đĄđ "
fi ;;
- up) wifiicon="$(awk -v pat="^\\s*$wireless" '$0 ~ pat { print "đļ", int($3) "% " }' /proc/net/wireless)" ;;
+ up) wifiicon="$(awk -v pat="^\\\\s*$wireless" '$0 ~ pat { print "đļ", int($3) "% " }' /proc/net/wireless)" ;;
# might need to do some calculations if this doesn't match up with `iwconfig` link quality
# up) wifiicon="$(awk '/^\s*e/ { print "đļ", int($3 * 100 / 70) "% " }' /proc/net/wireless)" ;;
esac
diff --git a/scripts/dwmblock-startbutton b/scripts/dwmblock-startbutton
@@ -0,0 +1,46 @@
+#!/bin/sh
+# dwmblocks script for do not disturb
+
+case "$BUTTON" in
+ 3)
+ case "$(printf 'Toggle DND\nToggle Sleep\nShutdown\nReboot' | dmenu -l 3 -i)" in
+ 'Toggle DND')
+ dunstctl set-paused toggle
+ pkill -RTMIN+13 dwmblocks;
+ ;;
+ 'Toggle Sleep')
+ if pgrep unsleep >/dev/null 2>&1; then
+ killall unsleep
+ notify 'Enabling sleep' ''
+ else
+ setsid -f unsleep >/dev/null 2>&1
+ notify 'Disabling sleep' ''
+ fi
+ pkill -RTMIN+13 dwmblocks
+ ;;
+ 'Shutdown')
+ if [ "$(printf 'Yes\nNo' | dmenu -i)" = "Yes" ]; then
+ systemctl poweroff
+ fi
+ ;;
+ 'Reboot')
+ if [ "$(printf 'Yes\nNo' | dmenu -i)" = "Yes" ]; then
+ systemctl reboot
+ fi
+ ;;
+ esac
+ ;;
+ 6) "$TERMINAL" -e "$EDITOR" "$0"
+ ;;
+esac
+
+s='ī '
+case "$(dunstctl is-paused)" in
+ true)
+ s="$sđ ";;
+esac
+
+if pgrep unsleep >/dev/null 2>&1; then
+ s="$sī´ "
+fi
+printf '%s' "$s"