You are not logged in.

#1 2015-10-17 20:09:03

rowra
Member
Registered: 2015-08-30
Posts: 24

[SOLVED] Automatically detect new screen

I'm using Gnome (but I'd like a general solution that'd work even if I switched to anything else).
Problem is that unless the screen is attached at boot already (aka I plug it in later, or attach the laptop to the dock station) the screen doesn't get turned on until I run "gnome settings". No need to set anything there, just need to run the applet and then it detects screens.

So what does it do? How can I automatize that?


Thanks

Last edited by rowra (2015-10-17 22:44:09)

Offline

#2 2015-10-17 20:12:44

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,999
Website

Re: [SOLVED] Automatically detect new screen

I would just add an `xrandr` command to ~/.config/autostart but I suspect there is a more "correct" method.

EDIT: My apologies, I completely misread the question.

Last edited by Head_on_a_Stick (2015-10-17 20:13:40)


Jin, Jîyan, Azadî

Offline

#3 2015-10-17 20:16:52

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [SOLVED] Automatically detect new screen


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#4 2015-10-17 20:20:18

rowra
Member
Registered: 2015-08-30
Posts: 24

Re: [SOLVED] Automatically detect new screen

jasonwryan wrote:

Thanks, I'll look into that. For now just a clarification of the question:

echo /sys/class/drm/*/status

does return a good handful of disconnected and only one connected (the built-in screen)
And the second screen (connected via DVID to the dock) only becomes "connected" when some magic-script-thing is run by something like the gnome-settings

edit the following code does initialize the second screen the way I want (mirrored):

xrandr --output LVDS1 --mode 1920x1080 --output HDMI3 --mode 1920x1080 --same-as LVDS1

Now I only need to look into udev rules to automatize it. Plus it'd be nice to get the variables (LVDS1, HDMI3) automatically too? Not that physical ports can wander around or anything, just to be more universal? Any ideas on that?

Last edited by rowra (2015-10-17 20:26:07)

Offline

#5 2015-10-17 20:28:09

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [SOLVED] Automatically detect new screen

You could awk/grep xrandr output for connected screens...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#6 2015-10-17 20:48:26

rowra
Member
Registered: 2015-08-30
Posts: 24

Re: [SOLVED] Automatically detect new screen

jasonwryan wrote:

You could awk/grep xrandr output for connected screens...


udev rule doesnt work somehow..

/etc/udev/rules.d/95-monitor-hotplug.rules looks like:

KERNEL=="card0", SUBSYSTEM=="drm", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/mark/.Xauthority", RUN+="/usr/local/bin/hotplug_monitor.sh"

And nothing happens on hotplug. (Script run manually does work and exist)

Offline

#7 2015-10-17 21:01:01

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [SOLVED] Automatically detect new screen


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#8 2015-10-17 21:40:46

rowra
Member
Registered: 2015-08-30
Posts: 24

Re: [SOLVED] Automatically detect new screen

There is something weird going on. I found out that Gnome does this automatically. If the laptop is docked (built in screen open and active) and then I plug in the secondary screen (into the dock, DVI), then it does get detected and attached.

However if the secondary screen is already attached to the dock, and I just dock the laptop, it does not get detected (aka it does not get sensed as a monitor plugged in).

The problem is, that even with a very own udev rule, the rule works and executes just fine in the first case, but nothing happens in the latter.


So, any idea on how I can trick this?

(Oddly, xrandr does find it and once it's run it's back in the business again)

Last edited by rowra (2015-10-17 21:46:32)

Offline

#9 2015-10-17 22:43:33

rowra
Member
Registered: 2015-08-30
Posts: 24

Re: [SOLVED] Automatically detect new screen

I got it working. The only workaround possible was to find out when it's connected to the dock (since apparently the dock itself handles the screen and therefore some weird magic is going on there in the background). The dock shows up as a USB device, so I could write a udev rule for that.

Also the only way I could makeit work (for now) was by calling a script that does nothing but call in another script with "/bla/bla/script &" and this way it actually executes properly.
Also, Xauthority is NOT in my home folder, but rather in /run/user/1000/gdm/Xauthority, since I'm (forced to be) using gdm (for the new GOA)

Thanks for the replies and the help, closing

Offline

Board footer

Powered by FluxBB