Thursday, February 7, 2013

pavolume.sh - control the active sink volume for pulseaudio

If you have multiple audio output devices, and you use keyboard bindings to control the master volume -> your system may get confused which master volume you want and select the first one by default. This script finds the current default active sink and changes the volume with it.

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 :
  1. 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.
  2. The 'inc' variable. This is the increment that each volume up/down request will preform. 5 is default.
  3. 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'.
  4. 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'.
  5. 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

switchaudio.sh - switching pulseaudio output

A script if you use multiple audio output devices and Pulseaudio. For instance USB  headphones and a regular internal sound card. This script makes it easy to switch between the different cards, and update any current applications to use the new output device. 

To execute just copy to a bin directory like `/usr/local/bin` and run `switchaudio.sh --next`.

You can bind this script to a key shortcut in KDE : systemsettings -> Shortcuts and Gestures

You can also find it: http://pastebin.com/a6T3ezFs