I have a custom build on Xubuntu 18.04, NVIDIA GTX 1050 graphics card and i'm trying to get the NVIDIA drivers to work. All methods i've tried so far cause the black screen with blinking cursor ([Ubuntu 18.10: Installing nvidia drivers leads to black screen after GRUB](https://askubuntu.com/questions/1085042/ubuntu-18-10-installing-nvidia-drivers-leads-to-black-screen-after-grub) and [Black screen at boot after Nvidia driver installation on Ubuntu 18.04.2 LTS](https://askubuntu.com/questions/1129516/black-screen-at-boot-after-nvidia-driver-installation-on-ubuntu-18-04-2-lts))

What i've tried:

* Installing from NVIDIA official runfile, from `ppa` repository, from choosing the driver in Additional Drivers, using versions 435, 440, 390
* Setting `nomodeset`, `nouveau.modeset=0`, `nvidia-rpm.modeset=1` in boot options
* Installing the `hwe` packages (following [Update killed lightdm and xfce4 (Ubuntu 16.04. 4)](https://askubuntu.com/questions/1020740/update-killed-lightdm-and-xfce4-ubuntu-16-04-4))

Removing `quiet splash` from boot options, i can see the error is "Failed to start Detect the available GPUs and deal with any system changes." (same as [Ubuntu hangs on boot after blackout- Detect the available GPUs](https://askubuntu.com/questions/990279/ubuntu-hangs-on-boot-after-blackout-detect-the-available-gpus)). 

I've tried replacing `lightdm` with `gdm3` but i get [Ubuntu 18.04 Login window loop](https://askubuntu.com/questions/1086367/ubuntu-18-04-login-window-loop).

I've no choice except use the Nouveau driver, but i'm experiencing the same problems as [Some icons and text randomly become invisible after waking up from sleep (Ubuntu GNOME)](https://askubuntu.com/questions/764361/some-icons-and-text-randomly-become-invisible-after-waking-up-from-sleep-ubuntu).

**UPDATE**: i did `apt purge gnome*` as i thought it would resolve the display issues. It did, but caused my system to shut down when waking up from suspend ([Ubuntu shuts down instead of suspending](https://askubuntu.com/questions/885649/ubuntu-shuts-down-instead-of-suspending)). Editing `/etc/systemd/login.conf` made it worse: it shuts down upon login instead ([18.04 shuts off immediately after login](https://askubuntu.com/questions/1183511/18-04-shuts-off-immediately-after-login)). I went to reinstall nvidia drivers, leading to boot being stuck on "Started apt Daily download activities" (similar to [Boot stuck at “started daily apt upgrade and clean activities” (18.10)](https://askubuntu.com/questions/1128959/boot-stuck-at-started-daily-apt-upgrade-and-clean-activities-18-10)). I powered off the laptop and set the timer for `apt` to start after booting, and it's back to "Failed to start Detect the available GPUs and deal with any system changes." Furthermore, `apt` is also broken; now `apt install` anything leads to [E: Unable to correct problems, you have held broken packages](https://askubuntu.com/questions/363200/e-unable-to-correct-problems-you-have-held-broken-packages).

**UPDATE 2:**

I downgraded the kernel from 5.3 to 4.15, then corrected the broken packages with `aptitude`. For some reason, the driver install worked after booting to shell, getting wifi (see <https://www.linuxbabe.com/command-line/ubuntu-server-16-04-wifi-wpa-supplicant> and editing `/etc/resolv.conf`) then:

```
apt purge gnome*
reboot
service lightdm stop
apt install nvidia*-390
aptitude install primus nvidia-settings nvidia-profiler
apt install xserver-xorg-input-*18.04*
reboot

```

I might test using the latest `nvidia-440` packages later.

I suspect it's the kernel and installing the `hwe` packages that made it work ([Nvidia drivers broken after kernel update (Ubuntu 18.04 + kernel 5)](https://askubuntu.com/questions/1163155/nvidia-drivers-broken-after-kernel-update-ubuntu-18-04-kernel-5)).

I also disabled display compositing in Window Manager Tweaks and i don't have the disappearing problems anymore (but it could be due to not using the buggy Nouveau driver).

**UPDATE 3:**
Upgrading the kernel to 4.15.0.91 gave me the black screen again and purging/reinstalling `nvidia*` didn't help. In the end i gave up and kept to 4.15.0.88.

Re-enabled display compositing and installed nvidia-440 without issues.

However, switching to Nvidia drivers causes [Screen brightness not working](https://askubuntu.com/questions/162317/screen-brightness-not-working). Running `xbacklight` gives `No outputs have backlight property`, but editing the brightness file and `xrandr` works. I got around this by assigning

```
perl -e 'foreach $line (`xrandr --verbose`) {if ($line =~ "Brightness: (.+)") {my $b = $1 + 0.1; `xrandr --output eDP-1 --brightness $b`; exit;}}'

```

to brightness-up.