From 00f9199e7b033450264c78fb9fa1e56928b8f8f8 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 18 Oct 2021 15:43:47 -0700 Subject: whitenoise script: attempt to detect whether earphones connected --- scripts/desktop/whitenoise | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/scripts/desktop/whitenoise b/scripts/desktop/whitenoise index ab86cfde..f8b1c4af 100755 --- a/scripts/desktop/whitenoise +++ b/scripts/desktop/whitenoise @@ -1,8 +1,19 @@ #!/bin/sh -cvlc --quiet --loop ~/annex/media/sounds/R*.ogg & -whitenoise=$! +# values for melete -- possibly if we query pulseaudio/pipewire instead we +# would not need to encode values like these +snd_card_num=0 +node_num=0x21 + +# to save battery power, only output the white noise if earphones connected +if grep -A4 "Node $node_num" "/proc/asound/card${snd_card_num}/codec#0" \ + | grep 'Amp-Out vals: \[0x00 0x00\]' >/dev/null; then + cvlc --quiet --loop ~/annex/media/sounds/R*.ogg & + whitenoise=$! +fi nmcli radio all off zenity --info --title="whitenoise" --text="whitenoise" nmcli radio all on -kill $whitenoise +if [ "x$whitenoise" != "x" ]; then + kill $whitenoise +fi -- cgit v1.2.3