Skip to content

Instantly share code, notes, and snippets.

@HansCz
Last active January 28, 2019 02:48
Show Gist options
  • Save HansCz/b4058c5ee605e897e3ada212d20cfcc3 to your computer and use it in GitHub Desktop.
Save HansCz/b4058c5ee605e897e3ada212d20cfcc3 to your computer and use it in GitHub Desktop.
The 'blank monitor at boot'-issue
- Trying to figure out how lightdm gets started
[... huge section with all the legwork omitted. Here's my summary]
1. The systemd boot process begins
2. At some point, the conditions in the systemd unit lightdm.service are met.
/etc/systemd/system/display-manager.service:
...
After=getty@tty1.service systemd-user-sessions.service plymouth-quit.service acpid.serviceon
...
3. Reaching the specified target in the boot process, the systemd service lightdm.service executes /usr/bin/lightdm
/etc/systemd/system/display-manager.service:
...
ExecStart=/usr/bin/lightdm
...
- Hypothesizing about where things go wrong
I am assuming that somewhere during execution of /usr/bin/lightdm is where the laptop screen blacks out, since it never reaches the lightdm login prompt - (this is still very uncertain - needs verification)
This is where Brandur suggests that the login prompt has indeed executed, but it is shown on a screen that is not connected (the thunderbolt-connected ThinkVision one). How might this be tested? maybe typing in the blind?
The big question is: does lightdm need to run startxfce4 before it can show the login prompt or not?
The fact that the login prompt is displayed in a graphical interface, would seem to suggest that X needs to be started before the login prompt can be shown.
If so, the issue might well be found in the configuration files that startxfce4 looks for, i.e. ~/.config/xfce4/xinitrc and /etc/xdg/xfce4/xinitrc, in that order.
Then again, the issue might also be found in some as yet unknown aspect of how how lightdm runs. In that case, it might be worth it to have a closer look at what exactly goes on in /usr/bin/lightdm, and to have a look at its configuration file again (/etc/lightdm/lightdm.conf), and possibly the active greeter's configuration file (/etc/lightdm/lightdm-gtk-greeter.conf).
After all, is the whole point of lightdm not to be able to choose between different session types, like i3, gnome and xfce4 BEFORE logging in? If so, it seems nonsensical that startxfce4 would be run before the login prompt even shows.
Also, I found that lightdm.conf has a relevant looking setting called display-setup-script. So maybe it sets its own display settings, and my hypothesis that startxfce4 is involved in the setting of the display is wrong.
So for now, the jury is still out.
- Trying my hypothetical fixes for the 'blank monitor at boot'-issue
First off, I'm going to dig in to lightdm.
/etc/lightdm.conf has an option under [Seat:*] called display-setup-script. So what if I do the following (inspired by https://wiki.archlinux.org/index.php/NVIDIA_Optimus#LightDM):
Create this file
/etc/lightdm/display_setup.sh:
#!/bin/sh
xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto
Maybe I need to do something different here? This is what Brandur suggested (from his proposed .xinitrc):
xrandr --output eDP-1-1 --primary
In any case, Make the script executable:
# chmod +x /etc/lightdm/display_setup.sh
Now configure lightdm to run the script by editing the [Seat:*] section in /etc/lightdm/lightdm.conf:
/etc/lightdm/lightdm.conf
...
[Seat:*]
display-setup-script=/etc/lightdm/display_setup.sh
...
Now reboot and your display manager should start.
Here goes. Be back later.
(Time passes)
It worked!
/etc/lightdm/display-setup.sh:
#!/bin/sh
xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --output eDP-1-1 --primary --mode 1920x1080
I can't really tell you why I did it, but just for kicks, I tried to run the script with:
...
xrandr --setprovideroutputsource modesetting NVIDIA-0
...
just to see what would happen. I then took a look at the stuff Brandur suggested and decided to try and exchange 'xrandr --auto' with something that would make certain the display appeared on the laptop screen. I came up with 'xrandr --output eDP-1-1 --primary'.
And it worked! Every time I boot up, the login screen now appears as it should on the laptop screen. No more blanking out.
After I finished fistpumping and running around yelling 'yessss!!!!', I got cocky, and thought 'hey, if I got this far... why not try to fix that the login screen appears at 4k resolution? I can barely see it!'. So I tagged on a '--mode 1920x1080', and everything is golden!
Damn, it feels good to have fixed this. Thanks Brandur.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment