Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

is there a way to adjust the system volume via commandline so that the default volume popup (the one that pops up when pressing the media keys on notebooks) is still shown.

I need this for my remote control. It'll be run using a lircrc file and irexec.

share|improve this question
add comment

3 Answers 3

up vote 12 down vote accepted

Install the xdotool Install xdotool package, and try issuing xdotool key XF86AudioLowerVolume and xdotool key XF86AudioRaiseVolume.

share|improve this answer
    
You might need to prepend that with DISPLAY=:0 (or another if your display is different) for the lirc user to be able to send it to the right place. Might not though. –  Oli Nov 12 '10 at 0:59
1  
Thanks alot! I did not need to set the DISPLAY variable... –  Lincoln Nov 12 '10 at 1:10
add comment

You could bind a shortcut to this script I've found in the Arch forums (needs the package 'libnotify-bin'):

#!/bin/sh

usage="usage: $0 -c {up|down|mute} [-i increment] [-m mixer]"
command=
increment=5%
mixer=Master

while getopts i:m:h o
do case "$o" in
    i) increment=$OPTARG;;
    m) mixer=$OPTARG;;
    h) echo "$usage"; exit 0;;
    ?) echo "$usage"; exit 0;;
esac
done

shift $(($OPTIND - 1))
command=$1

if [ "$command" = "" ]; then
    echo "usage: $0 {up|down|mute} [increment]"
    exit 0;
fi

display_volume=0

if [ "$command" = "up" ]; then
    display_volume=$(amixer set $mixer $increment+ unmute | grep -m 1 "%]" | cut -d "[" -f2|cut -d "%" -f1)
fi

if [ "$command" = "down" ]; then
    display_volume=$(amixer set $mixer $increment- unmute | grep -m 1 "%]" | cut -d "[" -f2|cut -d "%" -f1)
fi

icon_name=""

if [ "$command" = "mute" ]; then
    if amixer get Master | grep "\[on\]"; then
        display_volume=0
        icon_name="notification-audio-volume-muted"
        amixer set $mixer mute
    else
        display_volume=$(amixer set $mixer unmute | grep -m 1 "%]" | cut -d "[" -f2|cut -d "%" -f1)
    fi
fi

if [ "$icon_name" = "" ]; then
    if [ "$display_volume" = "0" ]; then
        icon_name="notification-audio-volume-off"
    else
        if [ "$display_volume" -lt "33" ]; then
            icon_name="notification-audio-volume-low"
        else
            if [ "$display_volume" -lt "67" ]; then
                icon_name="notification-audio-volume-medium"
            else
                icon_name="notification-audio-volume-high"
            fi
        fi
    fi
fi
notify-send " " -i $icon_name -h int:value:$display_volume -h string:synchronous:volume

Seems to work fine in Ubuntu 10.10.

share|improve this answer
add comment

I installed xmacro and added following lines to .lircrc:

begin
        prog = irexec
        button = KEY_VOLUMEUP
        repeat = 1
        delay = 2
        config = echo KeyStrPress XF86AudioRaiseVolume KeyStrRelease XF86AudioRaiseVolume | xmacroplay $DISPLAY
end
begin
        prog = irexec
        button = KEY_VOLUMEDOWN
        repeat = 1
        delay = 2
        config = echo KeyStrPress XF86AudioLowerVolume KeyStrRelease XF86AudioLowerVolume | xmacroplay $DISPLAY
end
begin
        prog = irexec
        button = KEY_MUTE
        config = echo KeyStrPress XF86AudioMute KeyStrRelease XF86AudioMute | xmacroplay $DISPLAY
end
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.