~emersion/kanshi#49: 
Feature request: Use regex in output name

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
}
Status
REPORTED
Submitter
github.com:Sweenu (unverified)
Assigned to
No-one
Submitted
1 year, 7 months ago
Updated
1 year, 7 months ago
Labels
enhancement

github.com:emersion (unverified) 1 year, 7 months ago · edit

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: https://github.com/swaywm/wlr-protocols/issues/68

github.com:emersion (unverified) 1 year, 7 months ago · edit

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

github.com:Sweenu (unverified) 1 year, 7 months ago · edit

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.

github.com:emersion (unverified) 1 year, 7 months ago · edit

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.

github.com:Alkindi42 (unverified) 1 year, 7 months ago · edit

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.

github.com:Sweenu (unverified) 1 year, 7 months ago · edit

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.

github.com:Sweenu (unverified) 1 year, 7 months ago · edit

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.

github.com:Sweenu (unverified) 1 year, 4 months ago · edit

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.

Register here or Log in to comment, or comment via email.