Local

..:: Home
..:: Legal
..:: Contact
..:: About
..:: RSS
..:: Log in

Links

..:: Fake Bill Gates
..:: Tap the Hive

A Random Quote

"One individual always has the answers to our problems. One is always there when called upon. No mortal can deter this individual. This person is you! You can overcome any obstacle. You can overpower any enemy. You can solve any problem. You can bypass any restriction. You can break any barrier. You can conquer any battle. You can destroy any fortress. You can pass any test. You can surpass any master. You can exceed all expectations. You can win any game. You can create a masterpiece. You can make anything work. You can outsmart anybody. You can do the impossible. You influence everyone around you,changing the world forever. Noting would be the same with you. Because... You are Mighty."

Controlling PCM Volume in Linux Via Command Line

Some people want a script to control PCM volume via command line. The guys over at the Gentoo forums gave me something to start with and then I put the rest of this together. You can use this in conjunction with any key or voice listener daemon to control your volume, or just use it directly at the shell.

If you want to wget it, here’s the command to do so:

sudo wget http://www.djlosch.com/source/volmute -O /usr/bin/volmute

And, here’s the script itself:

#!/bin/bash
volsetting=`amixer sget 'PCM' | grep off`
    case "$1" in
    mute)
        amixer sset 'PCM' mute
    ;;
    unmute)
        amixer sset 'PCM' unmute
    ;;
    toggle)
        if [[ x"$volsetting" = x"" ]]; then
            amixer sset ‘PCM’ mute
        else
            amixer sset ‘PCM’ unmute
        fi
    ;;
    increase)
        amixer sset ‘PCM’ 8%+
    ;;
    decrease)
        amixer sset ‘PCM’ 8%-
    ;;
    *)
        echo “This is not an acceptable command!”;
        echo -e “Use \033[01;33mmute\033[01;00;0m, \033[01;33mincrease\033[01;00;0m or \033[01;33mdecrease\033[01;00;0m as options!”;
        echo;
    esac

Once the script is in your $PATH (/usr/bin is for example), here’s the usage:

volmute increase    #increase PCM volume
volmute decrease    #increase PCM volume
volmute mute        #mute PCM volume
volmute unmute      #unmute PCM volume
volmute toggle      #toggle muting of PCM volume

Note that you’ll need to use the toggle function if you’re mapping your keyboard’s mute button, although Ubuntu now has most keyboards’ multimedia keys working out of the box.

Leave a Reply