pulseaudio-equalizer-ladspa / equalizer

Pulseaudio LADSPA Equalizer
GNU General Public License v3.0
138 stars 15 forks source link

Write config outside default.pa #28

Open memeplex opened 5 years ago

memeplex commented 5 years ago

It's common practice between users to store their dotfiles in a git repo. Saving app state in config files wreaks havoc with this practice since every time state changes a new commit is needed. Please allow to save state in an external file to be included from default.pa. This could be an option or simply the default behavior: for example, save your state in pulseaudio-equalizer.pa and just add the include line to default.pa.

glitsj16 commented 5 years ago

@memeplex Although I see your point, this might prove to be out of pulseaudio-equalizer's control as PA decides where to look for its configs/data in a per-user setup (default.pa). Do you happen to know if pulseaudio actually supports following include directions in default.pa? Can't find anything on that topic in the official PA documentation, it only mentions honoring environment vars.

memeplex commented 5 years ago

It supports including other files by doing:

.include /etc/pulse/default.pa

This line is a pretty standard way of opening your custom configuration, indeed.

glitsj16 commented 5 years ago

@memeplex Aha, didn't know that was actually supported, thanks for clearing that up. I was actually planning on adding support for PA environment vars over the weekend, was going over issues here in that context when I noticed your feature-request. Might as well try to add that in.

glitsj16 commented 5 years ago

PR https://github.com/pulseaudio-equalizer-ladspa/equalizer/pull/31 adds support for $PULSE_CONFIG. I'll need some more time to decouple pulseaudio-equalizer.pa from default.pa, but I'm working on it. Stay tuned.

memeplex commented 5 years ago

Does this mean I can launch the equalizer with a specific PULSE_CONFIG=xxx environment and expect it to use the config at xxx instead of the default one? Doesn't the equalizer auto launch when pulseaudio starts or creates a new sink or whatever in a way that I would be unable to control it's environment?

glitsj16 commented 5 years ago

@memeplex

Does this mean I can launch the equalizer with a specific PULSE_CONFIG=xxx environment and expect it to use the config at xxx instead of the default one?

You'll need to export the PULSE_CONFIG var independent of the equalizer, but yes, when you do so you can put the files normally residing under ~/.config/pulse wherever you prefer (obviously owned by your user).

Doesn't the equalizer auto launch when pulseaudio starts or creates a new sink or whatever in a way that I would be unable to control it's environment?

No. The whole point of this exercise is that you as user controls (part of) pulseaudio's environment. Leaving out running PA in system-wide mode, the following might help to get a feel for how this all lives-together-apart. In per-user mode there are two things in play, PulseAudio and the Equalizer. The latter is a way to control PA's default.pa file, so the soundserver is aware of user-set default sink, output controls (presets), mute status etcetera. As such the equalizer isn't actually running or autolaunching together with pulseaudio at all. In fact, once you've setup your preferred configuration, you'll rarely touch the equalizer CLI script and/or GTK GUI. Those are merely a (beautiful) way to shape your soundsystem, and they will silently stay out of the way until summoned explicitly. The PR mentioned above makes the equalizer script aware of the env var, so it can find and manipulate default.pa as usual. PulseAudio (the server) also needs to find the necessary files, that's where you need env vars for (as detailed in man pulseaudio) when you want to put those in a non-default location.

Now, as you know, pulseaudio is renowned for the wide variety of ways it can start (via pulseaudio.desktop in ~/.config/autostart or /etc/xdg/autostart, via dbus, via systemd user service units, ...). So it's crucial to make pulseaudio aware of the env vars as early as possible. That's why I'd recommend to export those in either /etc/profile or /etc/bash.bashrc or the likes, e.g.

...
export PULSE_CONFIG=/home/memeplex/pulse/default.pa
export PULSE_COOKIE=/home/memeplex/pulse/cookie
...

The PULSE_COOKIE var is not important for the equalizer, but without finding one PA will bork and refuse to start. Possible file layout on disk:

/home/memeplex/dotfiles-safe-pulse-location-of-choice
--- cookie
--- client.conf (optional)
--- daemon.conf (optional)
--- default.pa

Make a backup if you haven't already, and experiment away :smile: Hope this helps.

glitsj16 commented 5 years ago

@memeplex Due to some misreading/misleading documentation the former merge was wrongly using PULSE_CONFIG. Instead, one needs to manipulate the PULSE_CONFIG_PATH environment. The above instructions still work once you use that var. Fully tested and working as expected now. I guess that means dotfiles users can fix their pulseaudio-equalizer-ladspa setup accordingly.

memeplex commented 5 years ago

Sorry, I still don't understand how to set a different config file for the equalizer than for the rest of pulseaudio by using a globally exported variable.

I would understand it if I was able to call the equalizer with PULSE_CONFIG_PATH=~/config/pulse/equalizer pulseaudio-equalizer or something similar, but you seem to reject that possibility when you say:

You'll need to export the PULSE_CONFIG var independent of the equalizer

FFY00 commented 5 years ago

Just do export PULSE_CONFIG_PATH='~/config/pulse/equalizer pulseaudio-equalizer', In bash if you don't use export the variable is only set locally, you want to keep it between sessions.

memeplex commented 5 years ago

I know about bash and process environments. My point is that PULSE_CONFIG_PATH is global, not equalizer specific. But from your example I infer it defines a kind of mapping from application to config path, does it? I mean, in your example there is a path but also the command name. Suppose I wanted to map another command to another config (or everything else to the default config path). Is that possible?

FFY00 commented 5 years ago

Oh, I totally forgot the actual issue, which is pretty dumb since it's right there on the title. PULSE_CONFIG_PATH is just used to change the pulseaudio config path.

flittermice commented 5 years ago

As I understand from the first few comments, the goal is only to split the configuration into two parts using an .include directive in the well-known default.pa. Playing around with environment variables has IMHO nothing to do with the task of this issue. The reason why I am interested in this issue is this: When I activate the Equalizer my fine-tuned and hand-crafted default.pa (which consists of an .include /etc/pulse/default.pa and some additions) gets overwritten brutally. Swapping the loading of the Equalizer out into a short snippet would be a great and pragmatic solution for that. Maybe I should open another issue for that?

memeplex commented 5 years ago

Obviously I agree wrt the desirability of writing eq specific config in a separate file but "brutally overwritten" is an overstatement. The additional config is written in a neat separate section AFAICS. The main problem I see is state change. If your dotfiles are in a git repo it's annoying having to ignore some changes most of the time and it's dangerous automatically ignoring them all the time by adding the file to .gitignore.

flittermice commented 5 years ago

Back from vacation I tried to investigate this a little, but didn't come too far. My problem is that /usr/bin/pulseaudio-equalizer (and /usr/bin/pulseaudio-equalizer-gtk) - when using the commands enable-config and disable-config - are changing my default.pa too much: The original lines behind the EQ section always get dismissed. In some cases which I haven't yet found out my user default.pa even got overwritten with the contents of /etc/pulse/default.pa. This was why I wrote "brutally overwritten" above.

Whatever: I feel this should become another bug report. Surely, writing the config outside default.pa (and including it with .include) would make this obsolete. For now, as I found out the necessary EQ parameters, I will just insert the only line load-module module-ladspa-sink sink_name=ladspa_output.mbeq_1197.mbeq .... into my default.pa and refrain from using /usr/bin/pulseaudio-equalizer(-gtk).

mbb78 commented 3 years ago

The reason why I am interested in this issue is this: When I activate the Equalizer my fine-tuned and hand-crafted default.pa (which consists of an .include /etc/pulse/default.pa and some additions) gets overwritten brutally. Swapping the loading of the Equalizer out into a short snippet would be a great and pragmatic solution for that.

Yes, my card doesn't get detected at all if I don't set it in ~/.config/pulse/default.pa and it's very frustrating having to set it everytime I open Pulseaudio Equalizer. This file was a simple .include /etc/pulse/default.pa, followed by the default card and port settings and then the equalizer settings. Then this file started being replaced by /etc/pulse/default.pa. I also think it would be optimal to set EQ in a different file, but anyway, even if that's out of the scope, EQ settings should be added or replaced in the file, without replacing it.