Prevent applications to control master volume on Linux

6,978

Solution 1

This Gentoo wiki article might apply here : PulseAudio per-application volume control :

PulseAudio supports per-application volume control, but by default this doesn't do much as you can only control these volumes from the pulseaudio volume control utility. Meaning that in an application like Audacious, when the output device is set to PulseAudio, and the volume control is set to hardware, it will adjust the master volume control, not the per-application volume control.

To fix this behavior, set the following in /etc/pulse/daemon.conf

flat-volumes = no

Now whenever Audacious goes to adjust the volume, it will adjust the audacious only volume and thus you wont have multiple applications fighting over the master volume control.

Solution 2

If I interpret your issue correctly, this is the solution I found:

The Issue

When an application controls volume (e.g. sets it to max), it affects the system volume level, leaving applications' volume levels where they are, effectively "capping" them, requiring to readjust through e.g. pavucontrol every time.

Initial settings:
  system      |========o--------|
  application |========o--------|

Controlling application adjusts:
  system      |================o|
  application |========o--------|

Result when bringin system volume level down again:
  system      |========o--------|
  application |===o-------------|

The Solution

The setup in my case has three distinct places that seem to allow configuring the pulseaudio-daemon:

  1. /etc/pulse/daemon.conf
  2. ~/.pulse/daemon.conf
  3. ~/.config/pulse/daemon.conf

To decouple the master control (this is usually what e.g. system-wide hardware volume controls are mapped to) and have applications control their own volume, without either of the two affecting each other, the following worked for me:

  • set flat-volumes=no in 2.
  • make sure there are no flat-volumes settings in either 1. or 3.
  • restart pulseaudio:
    • pulseaudio -k
    • pulseaudio --start

The Result

Let

volume level be the value of the slider control and
volume gain be the effective sound pressure rocking your neighbors

  • The result will be
    1. an application that has its own sovereign volume level, and
    2. a global system volume level, that is also only affected by itself.
  • The application's resulting maximum volume gain (that comes out of your speakers) will be limited by whatever the system volume level is currently set to.
  • Increasing the system volume level will proportionately increase the effective volume gain the application produces through your output, but not its own volume level.

An Example

flat-volumes = yes
  1. Applications "push" the system volume up: E.g. system volume is at 60%; application volume moves freely below 60%, but "pushes" the system volume up when exceeding the current system volume
  2. An application may set volume to max (e.g. kodi in a case I had). If so, the system volume level gets set (to max), while other applications' levels stay where they are. Up to this point this behavior retains effective volume gain, but when the application that set volume to max quits, all levels stay where they are, keeping system volume at max and application volumes now capped at their relative position.
flat-volumes = no
  1. Application volume does not affect the system volume, at all.
  2. An application may set volume to max (e.g. kodi in a case I had). With flat-volumes disabled, it does not affect the system volume, but only its own, leaving all other application volume levels where they are.
Share:
6,978

Related videos on Youtube

Alex
Author by

Alex

Updated on September 18, 2022

Comments

  • Alex
    Alex over 1 year

    Whenever I change the volume in VLC, Rhythmbox, or a video on YouTube, it change the master volume, i.e. the system volume. How can I prevent this from happening?

    I'm running Debian 7.0.0 (wheezy) with xfce4, it seems to use PulseAudio, which I'm not familiar with. Here's a screenshot of the "Mixer" app that comes with xfce:

    enter image description here

    Yes I tried unchecking the "chain" icon there. I installed pavucontrol but there seems to be no option to change that:

    enter image description here

  • Alex
    Alex about 11 years
    Thanks, but it did NOT work. Both changing the volume from the pulseaudio GUI (as seen here) and from the application itself (here) change the system volume. I rebooted the computer after making the changes. I checked the file and the changes were indeed saved
  • harrymc
    harrymc about 11 years
    Debian wheezy apparently uses PulseAudio version 2.0-6.1. You might try out the above advice on version 3.0-1 available on the experimental distribution.
  • bossi
    bossi over 4 years
    Got the ame issue - or is it a different variant on it? The master and all application volumes are set to, say 35%. I start an application that sets master (and itself) to 100%, but leaves all others at their (now relative) 35%. I quit that application, master is at 100%, all applications now capped to 35% (I'm on Arch Linux). Still searching for a solution to this.