Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

Feature request: Use regex in output name #72

Open
sweenu opened this issue Feb 26, 2020 · 8 comments · May be fixed by #73
Open

Feature request: Use regex in output name #72

sweenu opened this issue Feb 26, 2020 · 8 comments · May be fixed by #73

Comments

@sweenu
Copy link

sweenu commented Feb 26, 2020

At work, we don't have a set workstation and therefore often change monitors (flex office). All the monitors are of the same brand and model however they all have a different hexadecimal number in their names, for example, three similar monitors will have those names:

  • Goldstar Company Ltd LG Ultra HD 0x0000EDE5
  • Goldstar Company Ltd LG Ultra HD 0x0000E7C8
  • Goldstar Company Ltd LG Ultra HD 0x00007FB9

It is a burden to have to add all of them one by one. I'd like to be able to use a regex like so:

{
  output "Goldstar Company Ltd LG Ultra HD .*" enable scale 2.0
}
@emersion
Copy link
Owner

One solution would be to simply match output names with fnmatch(3). Another solution would be to allow users to match only a particular vendor, model or serial.

Related: swaywm/wlr-protocols#68

@emersion
Copy link
Owner

Note, we already support * to match any output. Is that not enough for your use-case?

@sweenu
Copy link
Author

sweenu commented Feb 26, 2020

Unfortunately it is not enough for my use case because at home I have yet another monitor for which I need another conf.
Unless the most specific names takes precedence, in which case I could make it work.

Using fnmatch would indeed be a good solution.

@emersion
Copy link
Owner

emersion commented Feb 26, 2020

The first matching configuration will be picked, so specifying the home configuration first should work. It would be a good idea to document this behavior.

The only thing that makes me hesitate about fnmatch is that your workplace has only one manufacturer/model of monitors "by chance". Maybe your workplace will buy a few monitors of the same brand as your home setup and this solution won't work anymore.

@Alkindi42
Copy link

I think fnmatch is an interesting approach.

The only thing that makes me hesitate about fnmatch is that your workplace has only one manufacturer/model of monitors "by chance". Maybe your workplace will buy a few monitors of the same brand as your home setup and this solution won't work anymore.

Indeed it will not work every time. However, that leaves us the option to "group" profiles and do interesting things (until swaywm/wlr-protocols#68).
I will open a PR in this direction. I let you the final decision.

@Alkindi42 Alkindi42 linked a pull request Feb 26, 2020 that will close this issue
@sweenu
Copy link
Author

sweenu commented Feb 27, 2020

The first matching configuration will be picked, so specifying the home configuration first should work. It would be a good idea to document this behavior.

In that case it's good for my case indeed! However, I still think it would be a nice feature to have.
If two types of monitors existed at work, requiring different configuration each, then I would indeed need shell globbing.

@sweenu
Copy link
Author

sweenu commented Mar 5, 2020

I just had the use case at work where we now have a second kind of monitor (with only slightly changing names), needing another configuration.
With globbing I can solve this problem with one block while without, I need a new block for each monitor.

@sweenu
Copy link
Author

sweenu commented Jun 9, 2020

Any update on this? A PR is ready to be merged, it seems to me that there are no obvious drawback for the flexibility it gives.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants