Solved How to set permanent volume for a specific application?

Solved issue

damix9

Member
Joined
Jun 5, 2024
Messages
48
Reaction score
12
Credits
422
If an app lacks a volume option it always starts playing sound with 100% volume. If I change it with a slider in Pavucontrol, it gets less loud, but when the app stops playing sound and starts again, it's 100% loud.
 


Give us more specifics about which application you're talking about and on which distro you're using it.
 
I want an instruction suitable for any application. It may be an XY problem, but I have many apps that need this feature. An example is Radiotray-ng, browsers normally don't have a volume setting, I also have a Wine program for cuckoo clock, it doesn't have any homepage or something, so I can't give a link to it. May be this should be implemented on app level, but an app may be buggy or may lack this setting, so I think it would be a good feature for a sound server.
I'm now using Ubuntu, but I'm going to install a new distro. But it doesn't matter, it's not a distro-specific question. I don't have a requirement to use a certain distro. I don't even have a requirement to use Pulseaudio. If you know how to do it in Pipewire or in any combination of software, please give me the instruction.
 
Your GUI may have a general volume setting in your system tray, depending on which DE you are using. Each app uses its own config files so you may need to set the volume in each one. Look for little speaker icons in your system tray to try to set your master volume control. As far as whether an app will remember depends on the app. I use VLC to play video and audio files and it remembers pretty well. Your config files are likely to be stored in ~/.config/.

Signed,

Matthew Campbell
 
Besides that, different file types have different codecs, different encodings, different sample rates, different gain settings on the recording. The same file in vlc may have a different volume in parole. If I use the graphic equalizer plugin, it'll even be more different. If I go to youtube and watch a video, it may be too quit, and even though I don't the volume, the next one might be too loud, there is no such thing as a one size fits all volume. Even on television, the television show is too quiet and the commercials are too loud. There will always be a variance. mp3s can sound different than opus, or m4a files, even if I never change the volume.
 
Your GUI may have a general volume setting in your system tray, depending on which DE you are using.
I don't want to alter master volume.
As far as whether an app will remember depends on the app.
I know. But some don't remember. Pulseadio has a per-app volume setting, it's cool, but it's kind of incomplete. The set volume is valid while stream (aka sink input) exists. So it's not per-app, it's per-stream volume.
If Pulseaduio doesn't have this feature, I want to make sure it really doesn't. And may be something else has it, or there's some dirty hack like running a script when a stream starts or stops and backup-restore the volume.

There will always be a variance. mp3s can sound different than opus, or m4a files, even if I never change the volume.
I don't want to make volume unchangeble. Just to to make it persistent across sink input's starts/stops.
 
I want an instruction suitable for any application. It may be an XY problem, but I have many apps that need this feature. An example is Radiotray-ng, browsers normally don't have a volume setting, I also have a Wine program for cuckoo clock, it doesn't have any homepage or something, so I can't give a link to it. May be this should be implemented on app level, but an app may be buggy or may lack this setting, so I think it would be a good feature for a sound server.
I'm now using Ubuntu, but I'm going to install a new distro. But it doesn't matter, it's not a distro-specific question. I don't have a requirement to use a certain distro. I don't even have a requirement to use Pulseaudio. If you know how to do it in Pipewire or in any combination of software, please give me the instruction.
It sounds like you want the volume of an app that has sound to retain the volume setting that you set for the next time that you run it.

Perhaps see what pulseaudio modules you have running. For example running the following command, may show the module that appears to do what you are concerned about. The output is large so I have snipped it to just show the relevant module:
Code:
$ pactl list modules
<snip>
Module #536870914
        Name: module-device-restore
        Argument:
        Usage counter: n/a
        Properties:
                module.author = "Wim Taymans <[email protected]>"
                module.description = "Automatically restore the volume/mute state of devices"
                module.usage = "restore_port=<Save/restore port?> restore_volume=<Save/restore volumes?> restore_muted=<Save/restore muted states?> restore_formats=<Save/restore saved formats?>"
                module.version = "1.2.4"
<snip>
As the description helpfully indicates, this module function is to "Automatically restore the volume/mute status of devices", which seems to be exactly your concern.

One possible way of dealing with this issue is to unload this module that is restoring the volume.
Code:
pactl unload-module module-device-restore

That may work. To make it persistent for the user, a possible approach is to set a configuration in:
/home/$USER/.config/pulse/default.pa
with the following contents:
Code:
load-module module-device-restore restore_volume=false

For system-wide application of the config, use: /etc/pulse/default.pa.

Please bear in mind that configurations like this can take some "trial and error" application to get just what you want, and the above is a proposal which may or may not work without some modifications. In my own case, the machines here are all pipewire now, so the info supplied here may need amendment if things have been updated for pulseaudio which was the former sound server here when these sorts of configs were made. In any case, there does appear to be the means to achieve your aim. Some relevant manpages are:
man pulse-client.conf
man default.pa
man pulse-cli-syntax

Information on pulseaudio modules is here:

Some details and examples are here, but not exactly the issue at hand:
 
Last edited:
It sounds like you want the volume of an app that has sound to retain the volume setting that you set for the next time that you run it.
Not only for the next time I run app. Volume gets reset even when the same instance of an app stops playing sound and starts again (without restarting app process).

module-device-restore
It has nothing to do with my problem. You probably mean module-stream-restore.
I'm stupid! Pulseaudio actually has this feature, you need just
Code:
load-module module-stream-restore restore_device=false restore_volume=true
in your ~/.config/pulse/default.pa.
Thank you!
 
I'm really surprised that nobody told me it's the default behavior. Of course I know about module-stream-restore, I disabled it myself. And forgot. It's enabled by default, and pulseaudio restores per-stream volume after pause-play, no matter if the app cares about restoring volume or not.
 

Members online


Top