-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow all glob patterns in output configs #5629
base: master
Are you sure you want to change the base?
Conversation
62fde31
to
55e2b5e
Compare
f75c184
to
882164b
Compare
At this point this PR is really a refactor of the code that then allows glob matching to be done easily. The old behavior could be brought back just by changing the line that does the two |
efef283
to
bbcad89
Compare
I've split out the patch series as I've found that the initial refactor fixes at least one bug with the existing code, unrelated to the matching itself. |
I've been running this locally with no issues. Any comments on it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how I feel about this as a whole, but here are some comments.
Something to consider is swaybg (as well as anything that is compatible with swaybg_command
like oguri). We build a command based on the output configs. swaybg currently does not support globbing and would fail to correctly set the wallpaper. Additionally, the output command is unique in that it allows for multiple subcommands to be provided on the same line (for backwards compatibility). This may result in multiple output configs having a wallpaper for the same output glob pattern, which would result in the output being specified multiple times in the swaybg spawn command.
bbcad89
to
452a27c
Compare
I hadn't looked at |
Thanks for the review @RedSoxFan. Let me know if you think these two remaining things are ok and I'll do the |
That would require also restarting swaybg everytime an output is connected or disconnected. Currently, we only restart it when there would be a change. I think this would just make #3693 more visible. |
452a27c
to
d3f47e5
Compare
I've implemented the swaybg change with the restart on any output config change. Is the restart problem that swaybg doesn't even need to be restarted if the resolution changes because it can adapt by itself? It should only be restarted if we're altering the command line commands it receives? |
Correct. |
The simplest way I can think of to do that is to keep the command line between calls and just do a no-op if it's the same. It would mirror what happens on mode change with wlroots turning a mode set into a no-op. Seems simple to implement too. |
19eae2b
to
d641b95
Compare
I've implemented the check that the command is not the same, and confirmed that it eliminates the restarts when the background config hasn't changed. I think that takes care of the last issue discussed, but maybe there are other doubts about this. |
Instead of doing merges of output configs in several places just keep a list of all config changes and apply them in order when needed. Fixes swaywm#5632
To prevent config->output_configs growing unbounded as new output commands are issued, delete old commands whenever they have the same name and change the same things.
Instead of special casing "output * ..." just make output take all glob patterns.
Create a single background config per output that already incorporates all the globbing and merging.
When outputs have changed but none of that has resulted in a change in how swaybg should be run don't restart it. This avoids flickering the background to grey as a result of bug swaywm#3693, and is generally good to not churn through process termination and startup for a no-op.
d641b95
to
df9265b
Compare
I'm not a huge fan of this PR as a whole.
If others disagree with me, I won't block the PR from being merged (and will clear my requested changes review), but I doubt this will be getting an approval from me. @emersion I'm curious what your thoughts are on this PR |
I'll try to answer the objections if it helps with the discussion, but I can also close the PR if this is not really wanted.
My use case is for applying the same config to several screens of the same make and model. It's a common situation in hot-seat offices that all have the same monitors. That specific use case could potentially be implemented by itself by adding make/model match but I can see people wanting to do things like set variable refresh on all DisplayPort outputs and other conveniences. I agree this isn't a must have feature though, so if it has many other downsides it can just be scrapped.
From a quick calculation it seems to be less than 1000 bytes per output in the absolute worst case scenario. It can also result in less memory when you can use a glob whereas before several configs are needed. I don't think there's any platform sway is interested where it makes a difference either way.
There's a bit of extra calculation. If the processing cost was too high caching could be done relatively easily but there's no calculation that's particularly expensive here, so the simplicity seems like a win.
This should allow less cases of showing #3693 actually. It only ever restarts swaybg if it needs to be restarted because the command line has changed. With the existing code if you issue the exact same background command over swaymsg the background flickers even though nothing has changed. The As I said I'm happy to just close this if there's no interest. The globbing itself I've found helpful but the PR has ended up reworking the code. Maybe too much? It's less code that to me seems simpler with at least one bug fixed. |
Just noticed that the same feature request and equivalent PR also exists for kanshi: |
I've been running this for nearly 6 months with no issues now. Is there anything else I can help with in the discussion? |
As I stated elsewhere, I'm still not convinced globs are a good feature to have for output configs. |
@emersion hadn't seen your opinion on that then. I was asking because both this and the kanshi PRs have been left open but without any further discussion. Feel free to close this if you don't want the feature then. I'll have to make do without it. |
To be able to implement the glob patterns I had to refactor the code and fixed at least one bug in the process. The glob support is a single line change after that. If it would help I can submit a PR that doesn't change functionality at all and then make the glob pattern support a trivial PR on top of that. |
Sure, feel free to split the refactoring part up if it makes sense to merge it standalone. Disclaimer, I haven't looked again at the refactoring yet. |
The |
I'd also really appreciate this feature. A bit of background: My monitor changes id depending on which ports I use on my laptop and the monitor, so without globbing, I need to keep all permutations of the ids around. Any time I make a change, I usually have to change all of them too. There are around 10 desks at my office all which all have monitors of the same model, so glob matching would allow one line to adapt all 10 of them. So far, I've to reconfigure sway each time I use a new one, and keep around a pile of identifiers in my config. I understand the desire for optimisation, but 1kb memory and a few string comparisons when there's an output change seems a bit extreme; I'm sure there's much juicier targets for optimisations. |
I really need this feature! In my shared office, the screens have individual IDs, so I need to configure each one individually, which is super annoying, e.g.:
I would like to be able to do just:
|
I'd also really appreciate this feature. Shared office, lots of individual IDs in the screens. |
I just stumbled upon this thread. I've pondered about a complete solution over the last 2 years. I came up with a matching procedure that allows full text matching, substring comparison and regex matching for every monitor attribute individually. However, I don't think this procedure belongs into sways codebase for several reasons.
P.S.: Reading through this myself, it may seem like a self-promotion at first glance. Footnotes
|
The issue #6410 is a perfect example of what I meant with the shift of perceptibility of the underlying problem. When we look at them more broadly then both are about advanced output matching. What about matching a serial number? A complete solution can handle all of the above. |
The part of this PR that actually implements glob patterns is a single line. The more extensive changes were needed to replace the complex and error prone config merge code with a much simpler method of just applying all the rules all the time in the order the user specified them. That's how at least one bug is fixed by this. I've already offered to do a PR without the actual glob pattern single line change if that makes it easier. It would fix at least one bug and not have any functionality changes. The additional memory overhead is minimal. Since the glob pattern change is then a one-liner match difference I'd still have that over more complex stuff. It doesn't cover all cases but covers quite a few that are useful, most commonly the "office full of identical monitors with different serial numbers" setup. |
In principle, I agree with approaches like kanshi, swww or shikane, where an external client takes care of output-specific configuration. There's no need for the compositor to handle all this itself. In practice, the main issue is that these clients start after the compositor, so the compositor renders first with the default scale/resolution/rotation/etc and then the external client applies the correct settings. I can't think of a sensible way to work around this. The only thing that comes to mind is telling sway to delay rendering until a client has explicitly configured outputs... but honestly, this sounds like it could have a million edge cases where sway becomes unusable. |
Instead of special casing
output * ...
just make output take all glob patterns. This is useful if you want to change a config in all your HDMI or DP outputs, or want to match any monitor of a given model.This is implemented by just storing all output commands unaltered and then matching the glob patterns to the outputs whenever needed. Match order is the same as command introduction order so that any newer commands are always respected.
Code becomes significantly simpler by doing it this way, with a bunch of complex matching logic across several functions being replaced with a straightforward merge sequence in
find_output_config(sway_output)
.Fixes #5632