Prevent applications to control master volume on Linux

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.