alex-courtis / way-displays

way-displays: Auto Manage Your Wayland Displays
MIT License
241 stars 12 forks source link

ORDER gets confused by name which is substring of another (DP-1 < eDP-1) #60

Closed edrex closed 1 year ago

edrex commented 1 year ago

Prolog: First, thank you so much for writing way-displays. It is exactly the tool I have been wanting - so much so that I started writing one myself in zig awhile back - but better than I would have had time to implement. I greatly appreciate your work on this.

Issue: I can't seem to get the ORDER directive to have an effect.

I have a laptop with eDP-1 and DP-1 (HDMI via thunderbolt 3).

eDP-1 is always on top of the column, regardless of the ORDER in the config.

ARRANGE: COL
ALIGN: MIDDLE
ORDER:
  - 'DP-1'
  - 'eDP-1'
AUTO_SCALE: FALSE
SCALE:
  - NAME_DESC: 'eDP-1'
    SCALE: 2.0

The log reports the correct order:

I [15:53:06] Reloading configuration file: /home/edrex/.config/way-displays/cfg.yaml
I [15:53:06] 
I [15:53:06] New configuration:
I [15:53:06]   Arrange in a COLUMN aligned at the MIDDLE
I [15:53:06]   Order:
I [15:53:06]     DP-1
I [15:53:06]     eDP-1
I [15:53:06]   Auto scale: OFF
I [15:53:06]   Scale:
I [15:53:06]     eDP-1: 2.000
I [15:53:06] 
I [15:53:06] eDP-1 Changing:
I [15:53:06]   from:
I [15:53:06]     scale:    1.000
I [15:53:06]     position: 0,0
I [15:53:06]     mode:     3200x1800@60Hz (59,982mHz) (preferred)
I [15:53:06]   to:
I [15:53:06]     scale:    2.000
I [15:53:06]     position: 160,0
I [15:53:06] 
I [15:53:06] DP-1 Changing:
I [15:53:06]   from:
I [15:53:06]     scale:    1.000
I [15:53:06]     position: 640,1800
I [15:53:06]     mode:     1920x1080@60Hz (60,000mHz) (preferred)
I [15:53:06]   to:
I [15:53:06]     position: 0,900
I [15:53:06] 
I [15:53:06] Changes successful

related: #44

alex-courtis commented 1 year ago

It seem that we might be having some issues matching the name of the displays: eDP-1 contains DP-1.

Please try specifying the description instead: https://github.com/alex-courtis/way-displays/blob/master/doc/CONFIGURATION.md#on-names-and-descriptions

The names (DP-1, eDP-1 etc) are ephemeral and change depending on what hardware is plugged in etc. Description never changes.

edrex commented 1 year ago

Hey, good find, that that was it.

The DP-\d device identifiers indeed aren't stable, if multiple adapters are used, but eDP-1 is.

Semantically, the order rule I want is "external first (regardless of device name), then eDP-1 (name or desc doesn't matter, as both are stable identifiers barring a graphics card swap)". It seems like https://github.com/alex-courtis/way-displays/issues/46 would allow that.

I don't want to use desc for the external display, since I want a generic rule that works for whatever monitor I hook up to.

Mixing desc and name works for me for now: Update: this doesn't work reliably. See better workaround in follow up msg.

ORDER:
  - DP-1
  - "Sharp Corporation 0x144A 0x00000000 (eDP-1)"

I'd be happy to submit a fix for the unintended substring match if it's helpful.

alex-courtis commented 1 year ago

I don't want to use desc for the external display, since I want a generic rule that works for whatever monitor I hook up to.

Yes. That's a good use case.

I'd be happy to submit a fix for the unintended substring match if it's helpful.

That would be most gratefully appreciated!

edrex commented 1 year ago

Mixing desc and name works for me for now

Hmm, this morning I'm finding that sometimes this workaround isn't doing the job (maybe after device unplug/replug or suspend, not sure. Restarting way-displays seems to fix it.

I'd be happy to submit a fix for the unintended substring match if it's helpful.

Don't hold it for me, if you find yourself in that section of the code :sweat_smile:. I was feeling optimistic about my availability yesterday, which is a character flaw, but realistically I'm not sure when I'll have my plate clear enough to prioritize it.

edrex commented 1 year ago

Updated workaround: List out the descs of all displays used under ORDER.

alex-courtis commented 1 year ago

Hmm, this morning I'm finding that sometimes this workaround isn't doing the job (maybe after device unplug/replug or suspend, not sure. Restarting way-displays seems to fix it.

Perhaps that's an isue with unpredictable enumeration order of the outputs.

Don't feel any pressure to put in a fix; we will get to it eventually.

alex-courtis commented 1 year ago

Fixed in 1.7.0

I'd be most grateful if you tested this.

edrex commented 1 year ago

Thanks!

Preliminary testing looks good. Because it's nondeterministic I'll have to run it for awhile to feel confident it's fixed.