GhostNaN / mpvpaper

A video wallpaper program for wlroots based wayland compositors.
GNU General Public License v3.0
713 stars 21 forks source link

Chaining commandline arguments for multiple monitor #42

Open folliehiyuki opened 1 year ago

folliehiyuki commented 1 year ago

Currently if I want to set different videos for each monitor, I'll have to run multiple mpvpaper commands.

What I want is something like this (basically only 1 mpvpaper command to spawn all the mpv ones):

mpvpaper DP-1 "path/to/video1" DP-2 "path/to/video2"

The obvious benefit here is that I can manage mpvpaper as a user service for more fine-grained control (restart, stop, ...). For context, wlr-rand and swaybg have this design.

GhostNaN commented 1 year ago

It is not possible to spawn multiple libmpv render contexts. This is a hard limitation of mpv :

https://github.com/mpv-player/mpv/blob/88918411f3533e75df0ddce2cdeb25ce55804589/libmpv/render.h#L543-L579 "Currently, only at most 1 context can exists per mpv core (it represents the main video output)."

And spawning multiple mpv cores could get messy real fast for a small convenience.

The obvious benefit here is that I can manage mpvpaper as a user service for more fine-grained control (restart, stop, ...).

Create a shell script to run as a service with forking the program as seen here:

https://unix.stackexchange.com/questions/516749/how-best-to-start-my-systemd-service-to-run-multiple-apps

For context, wlr-rand and swaybg have this design.

wlr-rand is an output manager and has nothing to do with wallpapers. swaybg just displays an image with cairo

folliehiyuki commented 1 year ago

It is not possible to spawn multiple libmpv render contexts. This is a hard limitation of mpv :

https://github.com/mpv-player/mpv/blob/88918411f3533e75df0ddce2cdeb25ce55804589/libmpv/render.h#L543-L579 "Currently, only at most 1 context can exists per mpv core (it represents the main video output)." And spawning multiple mpv cores could get messy real fast for a small convenience.

Thanks for the explanation! If it is not possible to do due to mpv / not worth implementing, considering the small user cases, you can close the issue.

Create a shell script to run as a service with forking the program as seen here:

https://unix.stackexchange.com/questions/516749/how-best-to-start-my-systemd-service-to-run-multiple-apps

It works but that's not how systemd (or any kinds of service manager) should be used, and there are quite a few trade-offs. It's best to keep 1 service for each process.

My sole reason for this request is for automation, as dynamically managing multiple user services based on the current number of monitors is not practical. Running a one off script to spawn multiple mpvpaper commands just doesn't give me the benefits of using a service manager.

wlr-rand is an output manager and has nothing to do with wallpapers. swaybg just displays an image with cairo

I only mentioned them as examples of CLI programs with multiple arguments chaining, so we can take reference on how to structure the CLI part (if it ever get implemented). What their functionalities are and how they work doesn't matter. Sorry that the wording was clear there.

GhostNaN commented 1 year ago

This request isn't impossible, but it is hacky. I could make it so that mpvpaper could internally fork the process whenever there are multiple display args (although the terminal output would be ruined). Doing this any other way wouldn't work, so you're dealing with multiple process of mpvpaper either way.

GhostNaN commented 1 year ago

Almost forgot, the --auto-stop -s arg wouldn't be easily compatible with this idea.