Score:0

startx gives black screen with nvidia drivers

id flag

Some info:

distro: lubuntu 20.04
default dm - sddm
gpu - integrated intel, and Nvidia GTX 1650 mobile
nvidia drivers - nvidia-470

When I use the default display manager provided sddm the system works perfectly fine i.e i3 openbox every wm works.

But as soon as I use startx /usr/bin/i3 i get a black screen, i also created .xinitrc still same result. I also use another wm like openbox, i.e. openbox-session still same result.

I stopped sddm service and tried startx again still same result, i get black screen with no cursor. I switch to another tty and use htop and i can find that both xorg and i3 are running.

I checked the xorg log and it reports no error. prime-select query gives nvidia as result. If I use prime-select intel and then reboot the startx works. So I think I have to configure something when using nvidia.

How can I make startx work so I don't get a black screen ?

Thanks. If I should add some more information please tell I will add it.

htop preview of sddm

├─ /usr/bin/sddm
│  ├─ /usr/lib/x86_64-linux-gnu/sddm/sddm-helper --socket /tmp/sddm-auth1a548eff-e892-4543-89ec-705e1c6138a1 --id 1 --start i3 --user totoro
│  │  └─ i3
│  │     └─ /usr/bin/ssh-agent i3
│  ├─ /usr/lib/xorg/Xorg -nolisten tcp -auth /var/run/sddm/{36771d4e-9416-4be0-bfae-49c50dc60bc3} -background none -noreset -displayfd 17 -seat seat0 vt1
│  │  ├─ /usr/lib/xorg/Xorg -nolisten tcp -auth /var/run/sddm/{36771d4e-9416-4be0-bfae-49c50dc60bc3} -background none -noreset -displayfd 17 -seat seat0 vt1
│  │  ├─ /usr/lib/xorg/Xorg -nolisten tcp -auth /var/run/sddm/{36771d4e-9416-4be0-bfae-49c50dc60bc3} -background none -noreset -displayfd 17 -seat seat0 vt1
│  │  ├─ /usr/lib/xorg/Xorg -nolisten tcp -auth /var/run/sddm/{36771d4e-9416-4be0-bfae-49c50dc60bc3} -background none -noreset -displayfd 17 -seat seat0 vt1
│  │  ├─ /usr/lib/xorg/Xorg -nolisten tcp -auth /var/run/sddm/{36771d4e-9416-4be0-bfae-49c50dc60bc3} -background none -noreset -displayfd 17 -seat seat0 vt1
│  │  └─ /usr/lib/xorg/Xorg -nolisten tcp -auth /var/run/sddm/{36771d4e-9416-4be0-bfae-49c50dc60bc3} -background none -noreset -displayfd 17 -seat seat0 vt1
│  └─ /usr/bin/sddm

htop preview of startx

├─ /bin/login -p --
│  └─ -zsh
│     └─ /bin/sh /usr/bin/startx
│        └─ xinit /home/totoro/.xinitrc -- /etc/X11/xinit/xserverrc :1 vt2 -keeptty -auth /tmp/serverauth.czCRUMFwtc
│           ├─ /usr/bin/openbox --startup /usr/lib/x86_64-linux-gnu/openbox-autostart OPENBOX
│           └─ /usr/lib/xorg/Xorg -nolisten tcp :1 vt2 -keeptty -auth /tmp/serverauth.czCRUMFwtc
│              ├─ /usr/lib/xorg/Xorg -nolisten tcp :1 vt2 -keeptty -auth /tmp/serverauth.czCRUMFwtc
│              ├─ /usr/lib/xorg/Xorg -nolisten tcp :1 vt2 -keeptty -auth /tmp/serverauth.czCRUMFwtc
│              ├─ /usr/lib/xorg/Xorg -nolisten tcp :1 vt2 -keeptty -auth /tmp/serverauth.czCRUMFwtc
│              ├─ /usr/lib/xorg/Xorg -nolisten tcp :1 vt2 -keeptty -auth /tmp/serverauth.czCRUMFwtc
│              └─ /usr/lib/xorg/Xorg -nolisten tcp :1 vt2 -keeptty -auth /tmp/serverauth.czCRUMFwtc
galexite avatar
pk flag
It looks like your problem lies in your i3 configuration, not your drivers. Have you tried starting `i3-session` instead of `i3`?
Shivanshu avatar
id flag
Thanks for the response, no there is no `i3-session` command, also I tried `openbox-session` it also didn't worked.
Score:0
id flag

Since I'm using nvidia-prime, I have to add some lines in the .xinitrc for it to work. The display manager sddm does it too but I don't know where it's script is.

Add these lines to starting of .xinitrc

xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto

Source - NVIDIA-Optimus ArchWiki

Even better add some if,

DRIVER="$(prime-select query)"
if [ "$DRIVER" = 'nvidia' ]; then
    xrandr --setprovideroutputsource modesetting NVIDIA-0
    xrandr --auto
fi
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.