2

There is one application I missed back from Windows and it is Volumouse. Simple yet effective app which enables you to control volume from the whole taskbar (panel) not just from indicator icon. Especially if you use wireless mouse you'll appreciate how practical it is. Since there is no similar solution for Ubuntu it would be nice to have a script that covers it.

VRR
  • 1,270

3 Answers3

2

Modern mouse devices have more than one id when you run query xinput list. This script will cover those devices as well but first proper id must be determined. The selection is based on difference between outputs of xinput query-state <id> command and assumption that one id will have some key 245 in output, hence the line:

moid0=$(xinput query-state $moid1 | grep 245)

For your device the difference between outputs may vary, but you can use another keyword not 245 and change the line.
So the script look like this:

#!/bin/bash
vctrl1 () { 
    xinput test $mo | while read line
    do
        eval $(xdotool getmouselocation --shell)
        if [ $Y -gt 24 ]; then break
        elif [ "$wnn" != "Desktop" ] && [ $sd3 == $wg2 ]; then break
        elif [[ $line == "button release 5" ]] ; then
            xdotool key XF86AudioLowerVolume
        elif [[ $line == "button release 4" ]] ; then
            xdotool key XF86AudioRaiseVolume 
        fi
    done
}

sd1=$(xdpyinfo | grep dimensions)
sd2="${sd1#*dimensions:  }"
sd3="${sd2%% pixels*}"


while :
do
    moid=$(xinput list | grep -iPo 'mouse.*id=\K\d+')

    eval $(xdotool getmouselocation --shell)
    if [[ $Y -le 24 && ! -z $moid ]]; then

        wg1=$(xdotool getactivewindow getwindowgeometry)
        wg2="${wg1#*Geometry: }"

        wnn=$(xdotool getactivewindow getwindowname)

        read moid1 moid2 < <(echo $moid)
        moid0=$(xinput query-state $moid1 | grep 245)
        if [[ ! -z $moid0 ]]; then mo=$moid2 && vctrl1
        else mo=$moid1 && vctrl1
        fi
    elif [[ -z $moid ]]; then sleep 3
    fi
sleep 0.2
done

It will allow volume control with mouse wheel while hover over panel.

VRR
  • 1,270
0

If you want to change the volume with the mouse wheel, I have made Volumouse for Linux as you wish with config's options.

Look at this : https://github.com/pzim-devdata/volumouse :)

0

Also you can use this python script to control volume with mouse wheel from any place of your screen. Just edit code as you want. https://github.com/mnural/pyvolume

mnrl
  • 153
  • 1
  • 8