#!/bin/sh
# SPDX-License-Identifier: Unlicense

volumevalue=$(amixer sget Master | grep 'Right:' | awk -F'[][]' '{ print $2 }' | tr -d '%')
timeout=$1

if [ -z "$timeout" ]; then
	echo "Timeout missing!"
	exit 1
fi

if [ "$volumevalue" -eq 0 ]; then
	
	while [ "$volumevalue" -lt 100 ]; do
		volumevalue=$((volumevalue + 1))
		amixer -q sset 'Master' $volumevalue%
		echo $volumevalue
		sleep $timeout
	done

elif [ "$volumevalue" -gt 0 ]; then

	while [ "$volumevalue" -gt 0 ]; do
		volumevalue=$((volumevalue - 1 ))
		amixer -q sset 'Master' $volumevalue%
		echo $volumevalue
		sleep $timeout
	done

fi

