summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-10-18 15:43:47 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-10-18 15:43:47 -0700
commit00f9199e7b033450264c78fb9fa1e56928b8f8f8 (patch)
tree6a7b2902a9fc26396348d911f499f85e4c196ec2
parent7800b532dc7c4c42b8bc79b481612b6897348b42 (diff)
downloaddotfiles-00f9199e7b033450264c78fb9fa1e56928b8f8f8.tar.gz
whitenoise script: attempt to detect whether earphones connected
-rwxr-xr-xscripts/desktop/whitenoise17
1 files 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