Skip to content
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

List connected, but not activated(?) monitors? #6

Closed
AkkermanD opened this issue Dec 13, 2022 · 2 comments
Closed

List connected, but not activated(?) monitors? #6

AkkermanD opened this issue Dec 13, 2022 · 2 comments

Comments

@AkkermanD
Copy link

Hey! Thanks for the crate :)
I know nothing about xrandr, but I'm looking to implement toy-project to automatically activate/deactivate my external monitors when I'm connecting/disconnecting them.
I noticed that when I'm just pluggin in the external monitor it appears in the xrandr output:

HDMI-1 connected (normal left inverted right x axis y axis)
   1680x1050     59.88 +
   1280x1024     75.02    60.02  
   1152x864      75.00  
   1024x768      75.03    60.00  
   800x600       75.00    60.32  
   640x480       75.00    59.94  
   720x400       70.08  

This shows even if monitor is not "switched off" by button. But it is not listed in the XHandle::open().unwrap().monitors(). Is it possible to list the monitors that are not "activated" somehow?

@dzfranklin
Copy link
Owner

I'm not actively working with this crate, so you'd have to do this yourself. I have no idea how xrandr works either, I built this for a toy.

But: .monitors ends up calling a function called XRRGetMonitors

            unsafe { xrandr::XRRGetMonitors(self.sys.as_ptr(), self.root(), 0, &mut count) };

(In lib.rs:120)

And if you look into the autogenerated docs the third parameter is called get_active.

So what I would do in your position is try forking this crate and flipping that parameter from 0 to 1. If that works you could file a PR that exposes some nice API, which I'd be happy to merge.

Good luck! Feel free to ask more questions, I'll see if I remember anything relevant.

@AkkermanD
Copy link
Author

Thanks, Daniel! Will look into, not sure when, but I'll get to it :)

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

No branches or pull requests

2 participants