diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-15 11:25:50 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-15 11:25:50 +0200 |
| commit | 98fc6036ee817a92810e060c80d48aa6a936a1ab (patch) | |
| tree | e05b1b724463de10649180615ad32bb6094f84e0 /desktop/modules/status/test-notify-sound.sh | |
| parent | e22d2ccee82b829875fe343cf1be48975174b054 (diff) | |
| download | quickshell-98fc6036ee817a92810e060c80d48aa6a936a1ab.tar.gz quickshell-98fc6036ee817a92810e060c80d48aa6a936a1ab.zip | |
feat(status): quiet mode mutes the Claude and opencode sounds
A new registry mode, status.quiet, with a row on the status page. Both tools
will play their sounds through notify-sound, which asks statusctl and plays
nothing while quiet is on, so their popups stay and only the sound goes.
Presentation sets quiet and restores it afterwards, like dnd and nolock: a
sound during a call or a game is what quiet is for.
notify-sound ignores any argument it has no sound for, because the opencode
notifier runs its command on every event, session_started and user_message
included.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'desktop/modules/status/test-notify-sound.sh')
| -rwxr-xr-x | desktop/modules/status/test-notify-sound.sh | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/desktop/modules/status/test-notify-sound.sh b/desktop/modules/status/test-notify-sound.sh new file mode 100755 index 0000000..9571d4c --- /dev/null +++ b/desktop/modules/status/test-notify-sound.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# +# Copyright (C) 2026 Danilo M. <danix@danix.xyz> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# The one runnable check for notify-sound. A fake paplay first on PATH +# records what it was asked to play, and XDG_RUNTIME_DIR is a temporary +# directory, so no sound plays and the live quiet mode is untouched. +# +# Usage: ./test-notify-sound.sh (exit 0 = all passed) + +set -u + +here="$(cd "$(dirname "$0")" && pwd)" +tmp="$(mktemp -d)" +trap 'rm -rf "$tmp"' EXIT +export XDG_RUNTIME_DIR="$tmp" +export NOTIFY_SOUND_DIR="/sounds" +mkdir "$tmp/bin" +printf '#!/bin/sh\nprintf "%%s\\n" "$1" >> "%s/played"\n' "$tmp" > "$tmp/bin/paplay" +chmod +x "$tmp/bin/paplay" +export PATH="$tmp/bin:$PATH" + +pass=0 +fail=0 + +check() { + local label="$1" want="$2" got="$3" + if [[ "$want" == "$got" ]]; then + printf 'ok %s\n' "$label" + pass=$((pass + 1)) + else + printf 'FAIL %s: want %q, got %q\n' "$label" "$want" "$got" + fail=$((fail + 1)) + fi +} + +play() { + rm -f "$tmp/played" + "$here/notify-sound" "$@" + cat "$tmp/played" 2>/dev/null +} + +check "claude" "/sounds/claude-attention.opus" "$(play claude)" +check "permission" "/sounds/opencode-perms.opus" "$(play permission)" +check "complete" "/sounds/opencode-attention.opus" "$(play complete)" +check "error" "/sounds/opencode-attention.opus" "$(play error)" +check "question" "/sounds/opencode-attention.opus" "$(play question)" +check "an event with no sound" "" "$(play session_started)" +check "no argument" "" "$(play)" + +"$here/statusctl" quiet set 1 +check "quiet mutes claude" "" "$(play claude)" +check "quiet mutes permission" "" "$(play permission)" + +"$here/statusctl" quiet set 0 +check "quiet off plays again" "/sounds/claude-attention.opus" "$(play claude)" + +printf '\n%d passed, %d failed\n' "$pass" "$fail" +[[ "$fail" -eq 0 ]] |
