Support for different output name format
Currently, wl-mirror and wl-present seems to only support specifiing output aliases like 'DP-1', 'eDP-2', 'HDMI-1-A' etc... I tried with full screen name including model and serial number but it does not seems to work (or I am missing something).
I find this behavior not really reliable as output aliases can change depending on the order screen are plugged. It could be usefull to be able to identify screens with a criteria (similar to how kanshi identify screens)
you're right, artificially limiting wl-mirror to just wayland output names is bad for usability, scriptability, and might not even scale accross desktops.
This is a good suggestion, I will add something like make/model matching as well. I'm gonna look at what kanshi supports and try to behave similarly/the same as that tool.
I think I have an idea for a design for this:
- targets are matched as outputs by default, but can optionally be prefixed with
output: - output names are matched similarly to kanshi output critera. Matching order:
- output name (e.g. eDP-1)
- manufacturer/model/serial (e.g. Foocorp XB240H 12AQ4)
- targets prefixed with
toplevel:are matched as toplevels (for ext-image-copy-capture toplevel source) - toplevels are matched by their xdg-toplevel-list identifier or by app name and title, priorities or wildcards will still have to be decided
- other sources can be supported by backends using prefixes, such as potentially
workspace:for COSMIC workspace capture, or laterportal:to explicitly select xdg portal capture when it gets implemented.
So, my [hacky] solution so far is a wrapper-based fix.
I have created a small utility for mapping monitor EDID names to Sway outputs: https://gist.github.com/shymega/afaceb462b5da5c2c76776eb8642a539
The eventual plan is a wrapper to be executed by Kanshi's exec directive that calls the sway-map-to-output script, in command substitutions.
I thought I'd mention it here as a temporary fix for those who really need a solution ASAP, and can't wait.
EDIT: I've tested it with my kanshi wrapper, and it works pretty well. It's pretty rigid, given it needs to be fullscreen-output, and only works with newer wl-mirror, but it does work.
So, my [hacky] solution so far is a wrapper-based fix.
I have created a small utility for mapping monitor EDID names to Sway outputs: https://gist.github.com/shymega/afaceb462b5da5c2c76776eb8642a539
The eventual plan is a wrapper to be executed by Kanshi's
execdirective that calls thesway-map-to-outputscript, in command substitutions.I thought I'd mention it here as a temporary fix for those who really need a solution ASAP, and can't wait.
EDIT: I've tested it with my kanshi wrapper, and it works pretty well. It's pretty rigid, given it needs to be fullscreen-output, and only works with newer
wl-mirror, but it does work.
that's a nice stopgap in the meantime, but hopefully I'll get this issue done for v0.19.0.
I'll release v0.18.0 (proper, not -pre) sometime this week, and the next topic I will tackle is more flexible target specification, so exactly this issue.
wlroots apparently removed make/model information from wl_output just after the 0.19.0 release (replacing it with "Unknown Unknown"), so to do this and be future-compatible, wl-mirror would have to bind wlr-output-management, even if it doesn't actually manage outputs.
Also, Wayland's wl_output also doesn't contain the serial number, so multiple outputs of the same make and model can't be distinguished easily. There is a description field, but its syntax is not standardized across compositors.
I'll probably do this, but wlr-output-management will be an optional protocol, to allow wl-mirror to also work on other compositors. (if wlr-output-management is not available, make/model information from wl_output will be used).
I'm currently working on getting the target matching code refactored to allow this kind of matching. My initial testing branch shows it works, but I haven't integrated wlr-output-management yet and still need to significantly clean it up and test it.
The output matching will probably look like this:
- match output name (e.g.
eDP-1) - match output description (e.g.
Acer XB240H T1YEE0014200 (DP-3 via HDMI)on wlroots/sway) - match output make / model, if available (e.g.
Acer XB240H) - match output make / model / serial, using wlr-output-management (e.g.
Acer XB240H T1YEE0014200)
I have also considered matching on partial output description if the match ends on a word boundary (e.g. "Acer XB240H" is OK, but "Acer XB24" is not), but I'm not sure if that is preferable. Full compatibility with the syntax used by Kanshi can only be guaranteed with the wlr-output-management protocol approach.