How can I make the volume change in smaller increments?

Ubuntu 17.10 and later

It's worth noting that on Ubuntu 17.10 and later with GNOME Shell, there is already (albeit somewhat convoluted) kind of support for this.

Press Shift+XF86AudioRaiseVolume or Shift+XF86AudioLowerVolume (usually the dedicated volume up / down keys on the keyboard) to change the volume with a smaller step size.

enter image description here


Ubuntu 14.04 / 15.04 / 15.10 / 16.04 / 16.10 / 17.04

I finally have a proper solution for Trusty, Vivid, Wily, Xenial, Yakkety, and Zesty users. Rather than using a bunch of hacks or a script, I decided to fix the problem in the source code. I applied this patch (now broken) to gnome-settings-daemon Install gnome-settings-daemon and unity-settings-daemon Install unity-settings-daemon (some trivial modifications were made to the patch).

I have uploaded the packages to a PPA:

ppa:george-edison55/gnome-settings-daemon Launchpad logo (Click here for instructions on using PPAs.)

Once you've added the PPA, run:

sudo apt-get update
sudo apt-get upgrade

You will need to restart after installation completes. Once the packages have been upgraded, you can use the dconf command Manpage icon to change the volume increment:

dconf write /org/gnome/settings-daemon/plugins/sound/volume-step 2

(The default value is 6.)

Now when you press the volume keys, the volume will change in increments of 2:

enter image description here


11.10/12.04

From this bug-report it appears the volume-step key disappeared in 11.10 and has not (as yet) reappeared.

Thus, there isn't a simple straightforward configuration change that you can make to reduce the volume step.

Post #18 in the link gives an interesting workaround which involves using alsamixer increment and decrement capability together with sending notifications to the desktop.

However I couldn't get it to work - thus my take on the solution is based upon that post.

With this solution, the default volume step will be reduced to two-percent steps.


How to

Install the xbindkeys package (using Synaptic, or with sudo apt-get install xbindkeys).

Using your favourite text editor, create a file in your home folder called .volumeHack.sh and copy and paste the contents below into that file i.e.

gedit ~/.volumeHack.sh

Run chmod a+x .volumeHack.sh to make it executable.

Then edit the file ~/.xbindkeysrc and copy & paste the text below at the bottom of this file. i.e.

gedit ~/.xbindkeysrc

Logout and login

.xbindkeysrc

# Increase volume
#"amixer set Master playback 1+"
"sh ~/.volumeHack.sh -c up -i 2% -m Master"
    m:0x0 + c:123
    XF86AudioRaiseVolume

# Decrease volume
"sh ~/.volumeHack.sh -c down -i 2% -m Master"
    m:0x0 + c:122
    XF86AudioLowerVolume

# Toggle mute - this is not used here
#"amixer set Master toggle"
# m:0x0 + c:121
# XF86AudioMute

.volumeHack.sh

#!/bin/sh

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

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

#echo "command:$command"
#echo "increment:$increment"
#echo "mixer:$mixer"

if [ "$command" = "" ]; then
    shift $(($OPTIND - 1))
    command=$1
    exit 0;
fi

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

#echo "icon: $icon_name and $display_volume"