summaryrefslogtreecommitdiff
path: root/scripts/desktop/whitenoise
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/desktop/whitenoise')
-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