The room that prompted this had a television on HDMI with working PCM audio and nothing in the analog jack, and WirePlumber chose analog. A teacher who corrected it by hand then had to restart the browser before any sound came out. The policy is a pure function so it can be tested against that room rather than against a machine: an unavailable port is not a candidate, an analog port merely existing is not evidence of a cable, and an explicit AUDIO_OUTPUT overrides the lot. Twelve cases, the real room among them. The daemon follows PipeWire's own event stream rather than polling, and moves streams that are already playing, which is the part that stops a teacher having to close and reopen the browser. Co-Authored-By: Claude Opus 5 <[email protected]>
36 lines
865 B
Bash
Executable File
36 lines
865 B
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
# Light or dark, for a room whose teachers prefer one.
|
|
#
|
|
# There is one interface, not two. Both schemes are the same token file with
|
|
# the roles swapped, and Plasma applies them to the panel, the notifications,
|
|
# the window decorations and every dialog at once, so nothing has to be kept
|
|
# in step by hand.
|
|
|
|
usage() {
|
|
echo "usage: classroom-theme [light|dark|toggle|show]" >&2
|
|
exit 2
|
|
}
|
|
|
|
current() {
|
|
kreadconfig6 --file kdeglobals --group General --key ColorScheme 2>/dev/null \
|
|
|| echo EkklesiaDark
|
|
}
|
|
|
|
apply() {
|
|
plasma-apply-colorscheme "$1" >/dev/null
|
|
echo "$1"
|
|
}
|
|
|
|
case "${1:-show}" in
|
|
light) apply EkklesiaLight ;;
|
|
dark) apply EkklesiaDark ;;
|
|
toggle)
|
|
if [[ "$(current)" == EkklesiaLight ]]; then apply EkklesiaDark
|
|
else apply EkklesiaLight; fi
|
|
;;
|
|
show) current ;;
|
|
*) usage ;;
|
|
esac
|