Dotfiles/desktopenvs/hyprlua/scripts/getvol

10 lines
421 B
Bash
Executable File

#!/bin/sh
# Query PipeWire/PulseAudio for the default sink's volume via pactl.
# pactl outputs "Volume: ... / 75% / ..." — awk splits on "/" and picks field 2.
# xargs trims surrounding whitespace so we get a clean "75%" string.
perc=$(pactl get-sink-volume @DEFAULT_SINK@ | awk -F/ '{print $2}' | xargs)
# Strip the trailing "%" character using shell substring removal (${var::-1}).
num=$(echo ${perc::-1})
echo $num