theotherjimmy / autorandr-rs

like autorandr, but kdl and a daemon
38 stars 4 forks source link

Single xrandr command option #4

Open seqizz opened 3 years ago

seqizz commented 3 years ago

And for (at least my) last issue: Could you supply an option to issue single xrandr command instead of multiple?

I know it sounds weird, but some crappy hardware (*cough dell docks *cough) only works that way. I was using an old branch of autorandr, due to this limitation.

Thanks again :rocket:

theotherjimmy commented 3 years ago

autorandrd does not call xrandr, so I'm not entirely sure what you're after. I'm pretty confident that there would be some transitions that require disabling outputs before enabling them, and I think that's what xrandr dose.

theotherjimmy commented 3 years ago

I found out about the "disable-then-enable" (or "break-before-make") sequence by running xrandr with --dryrun. Perhaps it would be useful to see what xrandr is doing under the hood, and if I can make an optimization to improve this somehow. Note that trying to configure screens to be outside the current screen could generate errors: https://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt#n1055

theotherjimmy commented 3 years ago

Perhaps we could try setting the screen size to it's maximum and then scaling it back to the final size?

seqizz commented 3 years ago

autorandrd does not call xrandr, so I'm not entirely sure what you're after. I'm pretty confident that there would be some transitions that require disabling outputs before enabling them, and I think that's what xrandr dose.

It might be because of "max enabled screens should be lower than n" limitation, either from graphic card or dock. Autorandr also tries to keep at least 1 display always active. So it means when I connect 2 monitors, it won't disable my only (laptop) screen and try to enable all monitors, totals to 3 which might be breaking. The change caused firing single xrandr command with disabled screen as first parameter, which worked without issues, that's why I got stuck with my fork.

It could also be a sizing issue, I am potato on details of X :no_mouth:

theotherjimmy commented 3 years ago

Yeah, that's true that all hardware has a limitation on the number of enabled monitors. I have a video card that can only handle 2 monitors at a time, despite having 4 connectors, so when switching between outputs, I have to be sure that I don't try to enable more than 2. That's why autorandrd disables first, that way it enables the fewest monitors possible at every step. autorandrd also aggressively disables monitors if they need any sort of changes, seen here: https://github.com/theotherjimmy/autorandr-rs/blob/main/src/bin/autorandrd.rs#L126-L130

I'm not sure if this is the problem, but the switching could be an issue for your setup. I'm working on a change, that I will push to a branch, that eliminates the "break-then-make" by setting the screen size to something that we know will work and later clamping it back to a smaller size.

theotherjimmy commented 3 years ago

The aforementioned double-resizing seems to work. Note that this is now different from how xrandr does things. Xrandr switching to horizontal from vertical looks like:

➜ xrandr --output DP-1 --right-of DVI-I-1 --dryrun
crtc 0: disable
screen 0: 5120x1440 1194x336 mm 108.86dpi
crtc 0:    2560x1440  59.95 +0+0 "DVI-I-1"
crtc 1:    2560x1440  59.95 +2560+0 "DP-1"

where as autorandrd going to vertical from horizontal looks like:

INFO - Setting Screen Size 5120x2880
INFO - Configuring CRTC 729 to mode 733 at 0,1440
INFO - Configuring CRTC 730 to mode 752 at 0,0
INFO - Setting Screen Size 2560x2880
theotherjimmy commented 3 years ago

@seqizz Could you try the double-resize branch?

seqizz commented 3 years ago

Sorry for late reply. Didn't help too much, monitors is not switching on. Verbose output after plug&wait 10 secs&unplug:

Monitor configuration: Single
INFO - Setting Screen Size to 3840x1200
INFO - Configuring CRTC 63 to mode 2013 at 0,0
INFO - Configuring CRTC 64 to mode 2013 at 1920,0
Monitor configuration: Work-Desktop
INFO - Disabling CRTC 64
INFO - Configuring CRTC 63 to mode 97 at 0,0
Monitor configuration: Single

Config was still same:

[monitors.eDP-1]

[monitors.DP-3-3]
product = 'DELL U2415'
serial = '7MT016C94RAS'

[monitors.DP-3-2]
product = 'DELL U2415'
serial = '7MT016C94PKS'

[configurations.Work-Desktop]
monitors = ["DP-3-2", "DP-3-3", "eDP-1"]
[configurations.Work-Desktop.DP-3-2]
mode = "1920x1200"
position = "0x0"
primary = false
[configurations.Work-Desktop.DP-3-3]
mode = "1920x1200"
position = "1920x0"
primary = true

[configurations.Single]
monitors = ["eDP-1"]
[configurations.Single.eDP-1]
mode = "1920x1200"
position = "0x0"
primary = true
theotherjimmy commented 3 years ago

Hm That's strange indeed. It looks like I need to dump the output set as well. Does the laptop's screen turn off when you plun into the dock?

theotherjimmy commented 3 years ago

Also, something worth noting is that when Single is switched to, it's not changing the screen size. I'll have to include any failures in the log, as it seems that something is going wrong.

seqizz commented 3 years ago

Does the laptop's screen turn off when you plun into the dock?

Yes, it does.

I'll have to include any failures in the log, as it seems that something is going wrong.

Alright, waiting for the update then. I've just run it with -vvvv by the way, if there is another level please ping.

theotherjimmy commented 3 years ago

To my knowlage, there is no further log level.

theotherjimmy commented 3 years ago

Sorry, was working on PBP suspend/resume issues. The new version relies on there being enough virtual screen available to fit both configurations. I added logging for errors. 1) could you test the branch again? 2) Could you post the screen lines from xrandr ? Something like xrandr | grep Screen should print only the lines we care about. (for bonus points, pipe to xclip -i so that you don't have to use the mouse to copy)

Mine looks like:

Screen 0: minimum 8 x 8, current 2560 x 2880, maximum 16384 x 16384

This info will help, as I want to be sure that the maximum there is enough to fit both configs simultaneously.

seqizz commented 3 years ago

Output line from xrandr is:

Screen 0: minimum 320 x 200, current 3840 x 1200, maximum 16384 x 16384

It acted same with latest changes, here is how it did :eyes: :

$ target/release/autorandrd -vvvv example-config.toml
Monitor configuration: Work-Desktop
INFO - Disabling CRTC 64
INFO - Disabling CRTC 65
INFO - Setting Screen Size to 1920x1200
INFO - Configuring CRTC 63 to mode 100 at 0,0
Monitor configuration: Single
INFO - Setting Screen Size to 3840x1200
INFO - Configuring CRTC 63 to mode 185 at 0,0
INFO - Configuring CRTC 64 to mode 185 at 1920,0
Monitor configuration: Work-Desktop
INFO - Disabling CRTC 64
INFO - Configuring CRTC 63 to mode 100 at 0,0
Monitor configuration: Single

After plug out / plug-in / wait a while / plug out.

seqizz commented 3 years ago

Since it doesn't report any errors, I am still assuming this is a bug somewhere else. Xrandr/autorandr was also reporting no issues and even print screens are configured correctly while they are off. But really confused how the single-xrandr command is causing it to correctly function.

Also, maybe as a small bug: My "Single" configuration gave me some unusable screen space after removing the external monitors. arandr was showing my laptop screen was only using left half of the "real screen" and some apps (like alt-tab indicator) was half visible on the right corner. Now I have corrected it before taking a screenshot, but if it's not clear, I'll attach one next time I try.

theotherjimmy commented 3 years ago

That's truely strange. If there was no issue, I would expect that we would see another "Setting Screen Size" line, as your single config probably configures a single monitor.

seqizz commented 3 years ago

Here is the example, after removing the screens and going to single mode. Monitor has correct resolution, but xrandr reports X value of screen as 3840: image

theotherjimmy commented 3 years ago

Yeah, that's strange. This is probably a knock on effect of the fact that I don't know how to directly query the screen dims. Out of curiosity, does it enable panning?

theotherjimmy commented 3 years ago

Just when I thought I was out of ideas, I found a way to directly query the screen size. Further, I found a few issues with some of the screen size settings. When experimenting with this, I was able to recreate your issue! I think I got it, could you try the main branch again?

seqizz commented 3 years ago

does it enable panning?

I didn't actually try long so I am not confident, but I didn't notice panning.

But latest main branch seems to solve that problem :+1: Now the laptop screen is same with the real screen size.

Yet, the docked monitors still didn't activate, here is the plug - wait - unplug output:

Monitor configuration: Single
INFO - Before Config - Setting Screen Size to 3840x1200
INFO - Configuring CRTC 63 to mode 185 at 0,0
INFO - Configuring CRTC 64 to mode 185 at 1920,0
Monitor configuration: Work-Desktop
INFO - Disabling CRTC 64
INFO - Configuring CRTC 63 to mode 100 at 0,0
INFO - After Config - Setting Screen Size to 1920x1200
Monitor configuration: Single
theotherjimmy commented 3 years ago

The interesting thing is that the mode is different. Does the laptop's screen turn off or change resolution in any way? Honestly, this is all quite disappointing, because I'm out of ideas on what could be happening. It looks to me like the switch back to the builtin display works fine. What does xrandr say about the state of things after plugging in to the external monitor?

seqizz commented 3 years ago

Does the laptop's screen turn off or change resolution in any way?

After I plug in the external monitors? Laptop's screen turns off.

It looks to me like the switch back to the builtin display works fine.

Correct.

What does xrandr say about the state of things after plugging in to the external monitor?

As far as I can grab (while all monitors are switched off after I plug in the monitors), xrandr was reporting normally, like 2 external monitors are active and correctly configured.

Thanks for the effort though. Feel free to close this one. I agree, this must be a bug on hardware level. But I am still intrigued why it works with a one-line of xrandr..