Set default volume and brightness at login

Add three `systemd` user units that reset
volume, screen brightness, and keyboard backlight,
so that every session starts from a known state.

Values come from ~/.config/environment.d/50-defaults.conf,
and can be overridden per machine via an untracked 90-local.conf
This commit is contained in:
Alexander Hess 2026-08-28 15:06:04 +02:00
commit 1be5a25bfd
Signed by: alexander
GPG key ID: B46EDB4DFC26805D
9 changed files with 158 additions and 0 deletions

25
.local/bin/set-volume-default Executable file
View file

@ -0,0 +1,25 @@
#!/bin/sh
set -eu
# Loaded from ~/.config/environment.d/50-defaults.conf or a local override
VOLUME="${DEFAULT_VOLUME:?unset, check ~/.config/environment.d/}"
i=0
while ! wpctl status >/dev/null 2>&1; do
i=$((i + 1))
if [ "$i" -ge 20 ]; then
echo "no PipeWire sink after 10s" >&2
exit 1
fi
sleep 0.5
done
wpctl set-volume @DEFAULT_AUDIO_SINK@ "$VOLUME%"
wpctl set-mute @DEFAULT_AUDIO_SINK@ 0
echo "Set volume to $VOLUME%"