dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit 428fbcdce10441d85a391202d779bcf8d0ec9614
parent 40b7ded6834c148cdb3fe5b835371f8ba4cfce07
Author: Alex Balgavy <alexander.balgavy@spaceapplications.com>
Date:   Fri, 22 Dec 2023 23:54:16 +0100

Update dwmblock scripts

Diffstat:
Mscripts/dwmblock-battery | 2+-
Mscripts/dwmblock-bluetooth | 30++++++++++++++++++------------
Mscripts/dwmblock-internet | 2+-
Ascripts/dwmblock-startbutton | 46++++++++++++++++++++++++++++++++++++++++++++++
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"