More testing and fixes for volume functions.

This commit is contained in:
2025-11-10 17:18:24 -07:00
parent 50d3104f9f
commit ee7aa402aa

View File

@@ -29,19 +29,21 @@ function volume-usage {
volume-usage, volume-usage,
volume-help volume help, volume --help, volume -h volume-help volume help, volume --help, volume -h
EOF EOF
return "$1" return $1
} }
alias volume-help="volume-usage" alias volume-help="volume-usage"
alias vol-h="volume-help" alias vol-h="volume-help"
function volume { function volume {
if [[ "$1" == "--help" || "$1" == "help" || "$1" == "-h" ]]; then if [[ "$1" == "--help" || "$1" == "help" || "$1" == "-h" ]]; then
volume-usage volume-usage 1
return 1
fi fi
if [[ (-z "$1" && -z "$2") if [[ (-z "$1" && -z "$2")
|| "$1" == "--display" || "$1" == "display" || "$1" == "-d" || "$1" == "+d" || "$1" == "--display" || "$1" == "display" || "$1" == "-d" || "$1" == "+d"
]]; then ]]; then
volume-display volume-display
return 0
fi fi
if [[ "$1" == *"%"* || "$2" == *"%"* ]]; then if [[ "$1" == *"%"* || "$2" == *"%"* ]]; then
@@ -99,6 +101,13 @@ function volume {
amt="$1" amt="$1"
fi fi
regex='^[0-9]+$'
if ! [[ $amt =~ $regex ]]; then
echo "> ERROR: Amount '$amt' does not seem like a integer."
volume-usage 2
return 2
fi
if [[ -n "$dir" && -n "$amt" ]]; then if [[ -n "$dir" && -n "$amt" ]]; then
echo "> Changing volume by '$dir$amt%'." echo "> Changing volume by '$dir$amt%'."
amixer -q sset Master ${amt}%${dir} amixer -q sset Master ${amt}%${dir}
@@ -130,6 +139,8 @@ function volume-display {
} }
alias "vol-d"="volume-display" alias "vol-d"="volume-display"
## TBD/TODO ##
# Go up and down until cancelled. # Go up and down until cancelled.
#function volume-trip { #function volume-trip {
# curr eq amixer current readout # curr eq amixer current readout