From e896b4aa2fa981287aa8804ef4041e798e308eb7 Mon Sep 17 00:00:00 2001 From: remph Date: Sat, 21 Dec 2024 20:13:57 +0000 Subject: Allow a user to configure audio type to skip detection This should make swob a bit faster for eg. ALSA users (without pipewire nor pulse), at the cost of it checking config directories all the time rather than only when it starts wob. Really the check should be moved to the daemon side, the daemon should be a shellscript which calls set_vol and feeds it to wob, and the controller should just echo "$*" >$wobfifo. That's an idea --- swob.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/swob.sh b/swob.sh index 49e7675..d8d0f9e 100755 --- a/swob.sh +++ b/swob.sh @@ -4,16 +4,24 @@ set ${BASH_VERSION:+-o pipefail} -efu wobfifo=$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY.swob -wobini= +wobini= SWOB_AUDIO= -set_wobini() { +scan_confdirs() { for dir in ${XDG_CONFIG_HOME:+"$XDG_CONFIG_HOME"} ~/.config /etc "${0%/*}"/../etc; do - if test -r "$dir"/swob/wob.ini; then + test -d "$dir"/swob || continue + if test -z "$wobini" -a -r "$dir"/swob/wob.ini; then wobini=$dir/swob/wob.ini + fi + if test -z "$SWOB_AUDIO" -a -r "$dir"/swob/audio; then + SWOB_AUDIO=`cat "$dir"/swob/audio` + fi + if test -n "$wobini" -a -n "$SWOB_AUDIO"; then return fi done +} +new_wobini() { # fine, I will make my own wob.ini(5) wobini=${XDG_CONFIG_HOME:-~/.config}/swob/wob.ini echo >&2 "$0: no swob/wob.ini found; writing default to $wobini" @@ -41,7 +49,7 @@ start_wob() { # or any other IPC or SHM system mkfifo -m600 "$wobfifo" - set_wobini + test -n "$wobini" || new_wobini # spawn wob process with temporary file(s) { @@ -158,6 +166,7 @@ do_cmd_get_percent() { ## MAIN ## +scan_confdirs start_wob { -- cgit