dotfiles

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

commit 9b9595cd460ad66f3772ff04e49c6299a8536442
parent 0a371ec7e7ca44cd089276bae1fd26fb6f1f687e
Author: Alexander Balgavy <alexander.balgavy@spaceapplications.com>
Date:   Mon,  2 Oct 2023 17:38:58 +0200

dwmblocks: extra scripts

Diffstat:
Ascripts/dwmblock-bluetooth | 33+++++++++++++++++++++++++++++++++
Ascripts/dwmblock-emacs-org-clock | 10++++++++++
Ascripts/dwmblock-volume | 44++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 87 insertions(+), 0 deletions(-)

diff --git a/scripts/dwmblock-bluetooth b/scripts/dwmblock-bluetooth @@ -0,0 +1,33 @@ +#!/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 + pkill -RTMIN+8 dwmblocks + ;; + 3) + notify Bluetooth "Toggling bluetooth..." + rfkill toggle bluetooth + pkill -RTMIN+8 dwmblocks + ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" + ;; +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 " 🛑" +elif printf '%s' "$bt" | grep '^\s*Powered: no' >/dev/null 2>&1; then + printf ' ❌' +elif printf '%s' "$bt" | grep '^\s*Powered: yes' >/dev/null 2>&1; then + printf '' +fi diff --git a/scripts/dwmblock-emacs-org-clock b/scripts/dwmblock-emacs-org-clock @@ -0,0 +1,10 @@ +#!/bin/sh +# dwmblocks script for battery information +case "$BUTTON" in + 1) emacsclient -c -a '' -e '(when (org-clock-is-active) (org-clock-goto))';; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +if pgrep -f emacs >/dev/null 2>&1 && command -v emacsclient >/dev/null 2>&1; then + printf " 🕛 %.40s" "$(emacsclient -e '(if (org-clock-is-active) (substring-no-properties (org-clock-get-clock-string)) "")' | tr -d '"')" +fi diff --git a/scripts/dwmblock-volume b/scripts/dwmblock-volume @@ -0,0 +1,44 @@ +#!/bin/sh +# dwmblocks script for volume information +sink="$(pactl get-default-sink)" +source="$(pactl get-default-source)" +case "$BUTTON" in + 1) + pgrep -f pulsemixer || setsid -f "$TERMINAL" -e pulsemixer + pkill -RTMIN+6 dwmblocks;; + 4) + pactl -- set-sink-volume "$sink" +10% + pkill -RTMIN+6 dwmblocks + ;; + 5) + pactl -- set-sink-volume "$sink" -10% + pkill -RTMIN+6 dwmblocks + ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +case $(pactl get-sink-mute "$sink") in + "Mute: yes"*) + volume_icon='🔇' + ;; + *) + volume_icon='🔊' + ;; +esac +volume="$(pactl get-sink-volume "$sink" \ + | head -n 1 \ + | awk -v volume_icon="$volume_icon" -F ' / ' '{gsub(" ", "", $2); gsub(" ", "", $4); printf("%s %s %s", volume_icon, $2,$4)}')" + +case $(pactl get-source-mute "$source") in + "Mute: yes"*) + mic_icon='' + ;; + *) + mic_icon='🎤' + ;; +esac +mic="$(pactl get-source-volume "$source" \ + | head -n 1 \ + | awk -v mic_icon="$mic_icon" -F ' / ' '{gsub(" ", "", $2); gsub(" ", "", $4); printf("%s %s %s", mic_icon, $2,$4)}')" +printf "%s %s" "$volume" "$mic" +