Here is a small script to control audio volume. Feel free to modify the script as per need. Make sure pulseaudio is is up and running.
Filename: volchg.sh
Usage:
volchg.sh [+/-] [x]
volchg.sh --increase volume by 5%
volchg.sh + --increase volume by 5%
volchg.sh + 10 --increase volume by 10%
volchg.sh - --decrease volume by 5%
volchg.sh - 10 --decrease volume by 10%
Script
#!/bin/sh
#############################
### Volume Up/Down Script ###
#############################
# Specify increase or decrease
MODE=$1
# Percentage Change
VAL=$2
#Set defaut change to 5%
if [ -z "$2" ]; then
VAL=5
fi
#Get MAX Value
MAX_VOL=`amixer cget numid=3 | grep "max=" | cut -d, -f5 | cut -d= -f 2`
#Get current val
CURRENT_VOL=`amixer cget numid=3 | grep ":" | cut -d, -f2`
#UPDATE VOL
if [ "$MODE" = "+" ]; then
MUL=1
else
MUL=-1
fi
NEW_VOL=$(( ($CURRENT_VOL + ($MUL * (( $VAL * $MAX_VOL) / 100 ))) ))
PER_VOL=$(( ($NEW_VOL * 100) / $MAX_VOL ))
amixer cset numid=3 $NEW_VOL > /dev/null
echo "Volume Level: $PER_VOL%"
Have fun !!!
Filename: volchg.sh
Usage:
volchg.sh [+/-] [x]
volchg.sh --increase volume by 5%
volchg.sh + --increase volume by 5%
volchg.sh + 10 --increase volume by 10%
volchg.sh - --decrease volume by 5%
volchg.sh - 10 --decrease volume by 10%
Script
#!/bin/sh
#############################
### Volume Up/Down Script ###
#############################
# Specify increase or decrease
MODE=$1
# Percentage Change
VAL=$2
#Set defaut change to 5%
if [ -z "$2" ]; then
VAL=5
fi
#Get MAX Value
MAX_VOL=`amixer cget numid=3 | grep "max=" | cut -d, -f5 | cut -d= -f 2`
#Get current val
CURRENT_VOL=`amixer cget numid=3 | grep ":" | cut -d, -f2`
#UPDATE VOL
if [ "$MODE" = "+" ]; then
MUL=1
else
MUL=-1
fi
NEW_VOL=$(( ($CURRENT_VOL + ($MUL * (( $VAL * $MAX_VOL) / 100 ))) ))
PER_VOL=$(( ($NEW_VOL * 100) / $MAX_VOL ))
amixer cset numid=3 $NEW_VOL > /dev/null
echo "Volume Level: $PER_VOL%"
Have fun !!!