# Xorg & xrandr unable to see monitor plugged in after X org is running



## bdk (May 29, 2020)

I've been running FreeBSD 12.1 RELEASE GENERIC amd64 on a Thinkpad 450 as my daily use laptop for the past five months, and overall its been great. This one issue really is starting to drive me nuts however, and I've been unable to resolve it on my own or find a solution online after several attempts, so I thought I'd post here for advice. I'm running the i915kms driver installed via ports (rest of system is installed using pkg, but the pkg version wasn't working on 12.1 when I installed. I don't have anything in my Xorg configuration, just using the detected defaults.

Since I'm using this laptop as my primary computer these days, I often use it docked at my desk with an external monitor, keyboard, and mouse. If the Monitor is plugged when XOrg starts up, everything works fine. However if I plug the monitor in while XOrg is running, it never detects it and xrandr doesn't see it at all. The xrandr output when in this state looks exactly the same as if no monitor was connected. The same thing happens, even if I boot XOrg with the monitor, unplug it, and then plug it back in. I'd like to be able to use the laptop mostly docked, undock it to take it with me, and then redock it when I return, but currently this requires a reboot (or at least a restart of XOrg), which generally makes me think twice about it.

If I quit XOrg and go back to the terminal, the terminal appears on both the internal laptop monitor and the external monitor, so It appears that the kernel driver itself is seeing the monitor fine, I just can't figure out how to get Xorg to detect it or force it to reprobe and find it.

The problem exists both with the DVI and VGA Ports on the dock, as well as the built in VGA port on the laptop-- even with no dock involved the problem still occurs with the laptop's internal VGA. I've tried manually adding in the modeline and mode with xrandr and enabling it, but I get an error about "configure crtc 0 failed". I have a few tweaks to the i915 driver configuration in /boot/loader.conf, and I've tried removing all of those but it didn't make a difference.

I verified yesterday that this works fine for me on a Linux LiveCD, so the hardware seems to support it fine, I just can't figure out how to get FreeBSD to do it. Any advice would be very appreciated. Thanks.


----------



## Alexander88207 (May 29, 2020)

Hello *bdk,*

i had the same issue as you and it helped to set the external monitor as the only default device with x11/arandr.


----------



## bdk (May 29, 2020)

Alexander88207 said:


> Hello *bdk,*
> 
> i had the same issue as you and it helped to set the external monitor as the only default device with x11/arandr.



Hi, Thanks for the suggestion. I installed arandr, but I don't see anything in there about making a device a 'default' There's 'active' and 'primary' flags. My external monitor was already the 'primary' one. I also tried using arandr to disable my laptop screen completely, but it still didn't make a difference. Is setting the external monitor to 'primary' in arandr what you had in mind, or am I missing a setting?

Thanks


----------



## Alexander88207 (May 29, 2020)

Yeah with default was meant to set the external monitor primary and as the only active my bad.

Hm.. I can't think of anything now except that I still have xf86-video-intel installed.


----------



## tingo (May 29, 2020)

So `$ xrandr --output <outputname> --auto` doesn't work?


----------



## bdk (May 29, 2020)

tingo said:


> So `$ xrandr --output <outputname> --auto` doesn't work?


That's correct. It acts just like it would if you entered that command while no monitor is attached.


----------



## bdk (Jun 1, 2020)

A couple of more things I've tried unsuccessfully in the last couple of days: First, I installed and tried xf86-video-intel, with the same result. I also upgraded all my pkg's to the latest available, but no change. Finally I tried out a GhostBSD live image on my laptop with the same result. I figured if it worked under GhostBSD I could try to figure out what it was doing differently, but it didn't work there either. Hopefully someone has some advice as to else to try? Thank you for any suggestions.


----------



## tingo (Jun 1, 2020)

You could try to enter a new issue here https://github.com/FreeBSDDesktop/kms-drm/issues
so that graphics team is aware of the issue, maybe they can fix it.


----------



## Mjölnir (Jun 2, 2020)

bdk said:


> [...] However if I plug the monitor in while XOrg is running, it never detects it and xrandr doesn't see it at all. [...]



Do not use a VGA (D-SUB) cable, that's analog and can be problematic.  Instead, use a digital protocoll, i.e. HDMI or DisplayPort -> DVI.
Try adding `Option     "ReprobeOutputs" "YES"` to the `Section "Device"` of your driver, e.g. /usr/local/etc/X11/xorg.conf.d/intel.conf
Then, the monitor should be detected once you switch back and forth between the X11 and the text console with CRTL+ALT+F1 and ALT+F9


----------



## bdk (Jun 3, 2020)

mjollnir said:


> Do not use a VGA (D-SUB) cable, that's analog and can be problematic.  Instead, use a digital protocoll, i.e. HDMI or DisplayPort -> DVI.
> Try adding `Option     "ReprobeOutputs" "YES"` to the `Section "Device"` of your driver, e.g. /usr/local/etc/X11/xorg.conf.d/intel.conf
> Then, the monitor should be detected once you switch back and forth between the X11 and the text console with CRTL+ALT+F1 and ALT+F9


Thanks for the advice. I'm already doing most of my testing with DVI,and the Reprobe configuration didn't seem to make any difference, but I discovered a new data point from your third point: I can boot up with or without external monitor attached and do CTRL-ALT-F1 / ALT-F9 to switch back and forth between console and X over and over with no problem, but if I boot up with external monitor and then detach it, CTRL-ALT-F1 stops working. Instead the mouse pointer and cursor disappear the the X gui becomes unresponsive but doesn't change. Alt-F9 brings back the pointer and cursor and it works again. Its almost like it is indeed switching to the console but the screen isn't updating. Occasionally when I do this, X quits and restarts (when it quits I do see console text on both screens). Not sure what this means, but a new data point at least.


----------



## Mjölnir (Jun 5, 2020)

Well, I'd assume the console has no notion of _plug'n-play_, and I like it that way 
If you're bored, you may find exotic knobs for the new vt(4) in the sources...

BTW, do you have hald(8) enabled?


----------



## bdk (Jun 5, 2020)

mjollnir said:


> Well, I'd assume the console has no notion of _plug'n-play_, and I like it that way
> If you're bored, you may find exotic knobs for the new vt(4) in the sources...
> 
> BTW, do have hald(8) enabled?



If I'm at the  console it appears I can unplug and replug my monitor and it works as expected and mirrors the laptop screen whenever its plugged in. If I then switch back to F9 for XOrg, XOrg quits and restarts. I do not have hald enabled on my system.


----------



## Mjölnir (Jun 6, 2020)

bdk said:


> [...] If I then switch back to F9 for XOrg, XOrg quits and restarts. I do not have hald enabled on my system.


You should.  From the RTFM (_read the FINE manual_) hald(8): 
_hald is a daemon that maintains a database of the devices connected to
the system system in real-time. The daemon connects to the D-Bus system
message bus to provide an API that applications can use to discover,
monitor and invoke operations on devices._
I realize this might be too much technical Nerd-speech. What it basically means is that applications like your X11 GUI (_Graphical User Interface_) need hald(8) to discover physical (and maybe virtual, i.e. software) devices connected to your computer.  This includes mice, keyboard, joystick, monitors, AC/battery, etc.pp.  Thus you have a good chance to solve your issue with
`$ su -
# service hald enable
# service hald start`


----------



## Argentum (Jun 6, 2020)

mjollnir said:


> I realize this might be too much technical Nerd-speech. What it basically means is that applications like your X11 GUI (_Graphical User Interface_) need hald(8) to discover physical (and maybe virtual, i.e. software) devices connected to your computer. This includes mice, keyboard, joystick, monitors, AC/battery, etc.pp. Thus you have a good chance to solve your issue with



I agree. Seems that `hald` is needed here.


----------



## Mjölnir (Jun 7, 2020)

I have a very similar laptop (T450_s_), also used w/ and w/o docking station.
So if you do not succeed and in case I do not reply in this thread anymore, drop me a note.


----------



## bdk (Jun 7, 2020)

mjollnir said:


> You should.  From the RTFM (_read the FINE manual_) hald(8):
> _hald is a daemon that maintains a database of the devices connected to
> the system system in real-time. The daemon connects to the D-Bus system
> message bus to provide an API that applications can use to discover,
> ...


Thank you for the suggestion. I've enabled hald, but there's no change in behavior with the external monitor.


----------



## Mjölnir (Jun 7, 2020)

Since you mentioned the VGA port, I'll assume your monitor is not very modern.  It would help to narrow down the root cause of the problem if you try another one (else borrow from a friend).  I repeat my previous post concerning analog vs. digital connection: in general, analog causes more trouble.


----------



## eaosfu (Jul 28, 2020)

Have you tried running:


```
xrandr -d ':0' --nograb -q
```


----------

