Copy it to a bin dir like `/usr/local/bin` execute with :
- pavolume.sh --up
- pavolume.sh --down
- pavolume.sh --togmute (this will change the mute status to the opposite of what it is currently - useful for a single key that does both)
- pavolume.sh --sync (this will sync all of your current apps using the current active/default output to the same volume level)
In the beggining of the script you'll see four useful settings/variables :
- The 'osd' variable. If you want to display an OSD message when changing volume set to yes. It's setup for kde and the KOSD package - so you might have to install that.
- The 'inc' variable. This is the increment that each volume up/down request will preform. 5 is default.
- The 'capvol' variable. This will cap the max volume to 100% (since pulseaudio by default allows you to go over this limit). Defaults to 'yes'.
- The 'maxvol' variable. This will cap the maximum volume to another percent (capvol overrides this if set to yes). Pulse will keep increasing the volume to several thousand percent, so here you can set a much more respectable number. Defaults to '200'.
- The 'autosync' variable. This will automatically sync all your sink-inputs (apps) with the current volume of your output (speakers) whenever you change the volume. This is useful if you manage multiple outputs and have issues with the app volumes becoming out of sync with the output (they should move up/down together). If you like keeping apps at different volumes then you should change this to no, and maybe bind a keystroke for manual sync if you so desire.
If you wish to use kosd it's in portage for Gentoo:
- emerge -av kosd
- After installation you have to restart kde to get it to load.
If you wish to remove the volume cap (IE - have your max volume over 100%) you will need to apply the following patch to kosd. If you're using Gentoo (and you probably should be), all you need to do is put this patch in the `/etc/portage/patches/kde-misc/kosd/` directory.
You can also download the maxvol.patch here : http://pastebin.com/yCgVtmUZ
- Afterwards go to systemsettings -> Shortcuts and Gestures -> Custom Shortcuts -> Add new shortcuts bound to the commands listed above.
You can also download the script here : http://pastebin.com/ZqWt3A5q
Thank you! Worked on ubuntu 13.10 as well, with a couple of changes. I was also able to assign shortcuts to up/down/mute with a non-media keyboard! :-)
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThanks for this script!
ReplyDeleteI noticed a small bug if there is a sink with an index > 9 (e.g. a bluetooth device that you frequently disconnect and reconnect).
If the default sink is 1 and there is another one indexed 10, getCurVol return the voulme of both. This happens because
pacmd list-sinks |grep 'index: 1'
matches 'index: 10' as well. To avoid that the -w option of grep can be used, so the function should read:
function getCurVol {
curVol=`pacmd list-sinks |grep -wA 15 'index: '${active_sink}'' |grep 'volume:' |egrep -v 'base volume:' |awk -F : '{print $3}' |grep -o -P '.{0,3}%'|sed s/.$// |tr -d ' '`
}
[I removed my previous comment because of a typo. Couldn't an edit button.]
Thanks for the comment; I have updated it with the -w flag on grep, as well as making it compatible with new pulseaudio pactrl commands (no longer utilizes the --)
DeleteChanges for Ubuntu 16.04:
ReplyDelete1. Escape * in active_sink regex: awk '/\* ......
2. Change all set-sink-volumes from -- X% to "X%" (-- is no longer valid)
Also had to dos2unix it for some reason.
Thank you! :)
ReplyDeleteline 41: qdbus: command not found
ReplyDeletebut it shows the OSD.
I just set osd to no, and it keeps showing the OSD.
Appart from that it works.
Thnx!
btw I am running XUbuntu 18.4
try this:
ReplyDeletepactl set-sink-volume @DEFAULT_SINK@ +5%
This script required small changes to work with my ubuntu 18.04 and awesome window manger.
ReplyDeleteMy fork of the script: https://gist.github.com/mrozo/4d90cb21979520004db8ad6d8691d489
This script rocks ;]
For anyone else still finding this, I have a fork of this on GitHub with more features and bug fixes: https://github.com/marioortizmanero/polybar-pulseaudio-control
ReplyDelete