easyeffects icon indicating copy to clipboard operation
easyeffects copied to clipboard

CLI: `-l` exits 0 whether the preset loaded or not (unknown name, and presets added after startup)

Open Mark2Mac opened this issue 3 months ago • 4 comments

Summary

easyeffects -l <name> returns exit status 0 whether or not the preset was loaded, in two different ways. A script cannot tell success from failure, and one of the two cases is silent on stdout as well.

Version: 8.2.8 (Flatpak, commit 46a13512), running as easyeffects --service-mode, on Arch/CachyOS with pipewire 1:1.6.8 and wireplumber 0.5.15.

Measured

what was asked printed exit status
-l on a name that has never existed Specified preset does not exist. 0
-l on a .json dropped into the preset directory while the service runs — one that -p lists (nothing) 0
-l on an existing, known preset (nothing) 0

The three are indistinguishable to a caller that checks $?.

The second row is the surprising one

-p and -l disagree about which presets exist. The listing spawns a new process, which reads the directory and sees the file; the load goes to the running service, which scanned the directory once at startup and does not re-scan. So:

cp Music.json ~/.var/app/com.github.wwmm.easyeffects/data/easyeffects/output/probe.json
flatpak run com.github.wwmm.easyeffects -p          # lists "probe"
flatpak run com.github.wwmm.easyeffects -l probe    # exit 0, no output, nothing applied
# restart the service and the same command works

Because it prints nothing at all here, it looks exactly like a successful load.

The first row is the more serious one

When EasyEffects does know the preset is missing, it says so on stdout — and still exits 0. That is the case where a wrapper script has every reason to trust the exit status, and it is wrong.

Why it matters

Automating the audio profile is the natural use of this CLI — a script that selects a preset when a video call starts, or from a desktop shortcut. With exit status 0 in every case, the script has no way to notice that nothing happened, and the only reliable check is listening to the output.

An aggravating detail: db/*rc is written back lazily, so reading it to check whether a preset was applied gives a stale answer for a few seconds. Together the two make the CLI look non-deterministic.

Request

Return a non-zero exit status when the preset was not applied — both when the name is unknown and when the running instance cannot see it. Re-scanning the preset directory on an unknown name would also fix the second row, but the exit status is the part a caller depends on.

Mark2Mac avatar Aug 26 '26 22:08 Mark2Mac

the load goes to the running service, which scanned the directory once at startup and does not re-scan.

That is not true. It does.

cp Music.json ~/.var/app/com.github.wwmm.easyeffects/data/easyeffects/output/probe.json flatpak run com.github.wwmm.easyeffects -p # lists "probe" flatpak run com.github.wwmm.easyeffects -l probe # exit 0, no output, nothing applied

At least with a native package that works. The new preset file loads.

wwmm avatar Aug 27 '26 00:08 wwmm

You're right, and my second claim was wrong. Re-tested on 8.2.8 (Flatpak) with a preset created while the service was already running: -p lists it, and -l applies it. I verified against the live pipeline this time — with a stream connected, the ee_soe_* PipeWire nodes change to exactly the new preset's plugin chain.

My "nothing applied" came from a bad instrument: I looked at the db/*rc files and at -s. The config is written on exit, and the filter chain is torn down when no stream is connected, so an idle check a few seconds later shows the same thing whether the load worked or not. Sorry for the noise.

Two things do survive, and the first is what made me misread the rest:

  1. easyeffects -l NoSuchPreset prints Specified preset does not exist. on stdout and exits 0; easyeffects -l Music (valid, and confirmed applied) prints nothing and exits 0. A script has no way to tell a failed load from a successful one except by string-matching stdout.
  2. -s and -a output return empty even immediately after a load I confirmed took effect on the live pipeline.

Happy to retitle this to the exit code and the reporting behaviour, or close it and open a clean one — your call.

Mark2Mac avatar Aug 31 '26 08:08 Mark2Mac

easyeffects -l NoSuchPreset prints Specified preset does not exist. on stdout and exits 0;

Strange. This message is followed by QCoreApplication::exit(EXIT_FAILURE);. It looks like the proper thing to do.

wwmm avatar Aug 31 '26 15:08 wwmm

That pointed me at something I had not tested: what happens when there is no instance to hand the argument to. Measured on 8.2.8 Flatpak, same build as before.

condition easyeffects -l NoSuchPreset
service instance running prints Specified preset does not exist. on stdout, exits 0
no instance running does not exit at all — it starts the application and stays up

So the exit(EXIT_FAILURE) you are looking at is not reached in either case that a user hits: with a running instance the invocation is a secondary that returns 0, and with no running instance the process becomes the primary and keeps going instead of terminating.

One limit I should state rather than hide: in the second case I killed it after three minutes, so what I know is that it did not exit in that window — not what code it would eventually have returned.

If it helps narrow it: -q from a second invocation does kill the running service, so the argument does reach the primary; it is the status that does not come back.

Mark2Mac avatar Aug 31 '26 16:08 Mark2Mac