Last active
August 29, 2015 13:59
-
-
Save j6s/10585878 to your computer and use it in GitHub Desktop.
bash alias: set Volume
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------------------------------- LINUX ------------------------------- | |
# for Linux (requires alsa-utils which is installed on most major distributions) | |
# usage: | |
# set volume to 50% | |
# $ vol 50% | |
# increase volume by 10% | |
# $ vol 10%+ | |
# decrease volume by 25% | |
# $ vol 25%- | |
alias volume='amixer -D pulse sset Master' | |
alias vol='volume' | |
# ------------------------------- OS X ------------------------------- | |
# for OS X (no requirements) | |
# usage: set the volume as a number between 0-7 | |
# $ vol 5 | |
function vol { | |
osascript -e "set Volume ${1}" | |
} | |
# volume ramper for OS X | |
function volr { | |
# as you would expect, you pass the endvolume to this script | |
endvol=$1; | |
# getting the current volume (0-100) and converting it to (0-7) | |
startvol=$(osascript -e 'set ovol to output volume of (get volume settings)'); | |
startvol=$(($startvol * 7 / 100 + 1)) | |
# the increment to use | |
increment=0.1 | |
# make the increment negative if the volume should ramp down | |
if [ $endvol -lt $startvol ] | |
then | |
increment=$((-$increment)) | |
fi | |
# echo the start volume | |
echo -n $startvol; | |
for i in $(seq $startvol $increment $endvol) | |
do | |
# clear the line and output the new volume | |
echo -ne "\r\r\r $i"; | |
vol $i; | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment