-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
The current brightness and volume bar scripts require a Python installation as well as some Python libraries.
I propose we also suggest some simpler shell scripts with minimal dependencies.
Here are some implementations I've come up with, they work for me but I'm new to shell scripting so there is probably room for improvement:
Brightness bar requires only inotify-tools
#!/bin/sh
# Change below to suit your system
BACKLIGHT="/sys/class/backlight/amdgpu_bl0"
BRIGHTNESS="$BACKLIGHT/brightness"
MAX_BRIGHTNESS=$(cat "$BACKLIGHT/max_brightness")
inotifywait -m -e modify "$BRIGHTNESS" \
| while IFS= read -r line; do cat $BRIGHTNESS; done \
| xob -m "$MAX_BRIGHTNESS"Volume bar requires only alsa-utils
(and optionally Wireplumber with Pipewire)
#!/bin/sh
# Wait for amixer to become available
until [ "$(amixer)" ]; do sleep 0.1; done
# `amixer events` always emits 1 event from the start, so we must skip it
skip=1
stdbuf -oL amixer events |
while IFS= read -r line; do
case ${line%%,*} in
('event value: numid='[34])
if [ "$skip" -eq 0 ]; then
# The `0+$2` below is to remove the '%' sign
amixer sget Master |
awk -F'[][]' '/Left:/ {print 0+$2 ($4 == "off" ? "!" : "")}'
# Using Pipewire/Wireplumber:
#wpctl get-volume @DEFAULT_AUDIO_SINK@ |
# awk '{ gsub(/\./, "", $2); print $2 ($3 == "[MUTED]" ? "!" : "")}'
else
skip=$(( skip - 1 ))
fi
esac
done | xobReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels