Getting KDE Plasma 5 to work with the NVIDIA closed-source driver in Gentoo Linux

Up until a few days ago I had avoided migrating from KDE 4 to KDE Plasma 5, Frameworks 5 and Applications 5 — I’ll refer to the latter three package categories collectively as ‘KDE:5’ — on my main laptop, a Clevo W230SS with NVIDIA Optimus hardware and Gentoo Linux Stable Branch installed. My reluctance to migrate to KDE:5 was because of various problems I experience in KDE:5 on my Compal NBLB2 laptop, which has Gentoo Testing Branch installed (currently Plasma 5.7.1, which you would expect to be less buggy than Plasma 5.5.5 in the Gentoo Stable Branch).

Recently the maintainers of Gentoo’s KDE ebuilds removed some of the KDE 4 ebuilds and made some of the other ebuilds dependent on KDE:5. It became more complicated and convoluted to keep KDE 4 going, so I reluctantly threw in the towel and migrated to KDE:5 on my main laptop. I wish I could have kept KDE 4 on that machine, as KDE 4 worked extremely well (and looked great too).

My first problem after migrating was the infamous black screen in X Windows at start-up. Trying the various suggestions in the Gentoo Wiki did not help and, for the first time since I’ve owned the Clevo laptop, I was glad it has NVIDIA Optimus hardware as I was able to change from using nvidia-drivers to using xf86-video-intel, which got me to a usable Desktop after I switched desktop managers from SDDM (see the system log file error messages below) to LightDM.

Jul 17 04:32:37 clevow230ss sddm-helper[3245]: PAM unable to dlopen(/lib64/security/pam_systemd.so): /lib64/security/pam_systemd.so: cannot open shared object file: No such file or directory
Jul 17 04:32:37 clevow230ss sddm-helper[3245]: PAM adding faulty module: /lib64/security/pam_systemd.so

Although I had merged x11-misc/sddm with USE="-systemd" because my installation uses OpenRC, the above error messages made me suspect that something is wrong with the sddm-0.13.0-r3 ebuild, which is why I switched to LightDM.

However, using solely the Intel driver is not a long-term solution for me because DraftSight CAD software is slower with the Intel driver, so I was keen to get Plasma 5 working with the closed-source NVIDIA driver (I do not want to use Bumblebee).

I managed to get LightDM and Plasma 5 working with nvidia-drivers by doing the following:

  1. Merge x11-misc/lightdm.
  2. Re-merge kde-plasma/plasma-meta with USE="-sddm".
  3. Remove the x11-misc/sddm package and kde-plasma/sddm-kcm package by using the command ‘emerge --ask --depclean‘.
  4. Edit the file /etc/lightdm/lightdm.conf to add the line ‘greeter-session=lightdm-kde-greeter‘ as specified in Gentoo Wiki article LightDM.
  5. Edit the file /etc/lightdm/lightdm.conf to add the line ‘display-setup-script=/etc/X11/Sessions/plasma‘ (any file name would do).
  6. Create the above-mentioned Bash script /etc/X11/Sessions/plasma containing the following:
#!/bin/bash
GPU=`eselect opengl list | grep \* | awk '{ print $2 }'`
if [ "$GPU" = "nvidia" ]; then
    xrandr --setprovideroutputsource modesetting NVIDIA-0
    xrandr --auto
fi

I can now switch between the NVIDIA closed-source driver and the Intel open-source driver using the method described in an earlier post: Switching between Intel and NVIDIA graphics processors on a laptop with NVIDIA Optimus hardware running Gentoo Linux.

Advertisements

About Fitzcarraldo
A Linux user with an interest in all things technical.

3 Responses to Getting KDE Plasma 5 to work with the NVIDIA closed-source driver in Gentoo Linux

  1. Pingback: Fixing all-white log-in screen when using the LightDM KDE greeter with Plasma 5 in Gentoo Linux | Fitzcarraldo's Blog

  2. Fitzcarraldo says:

    Gentoo Linux recently dropped the LightDM KDE Greeter due to a lack of maintenance upstream. In any case, I had already switched to the LightDM GTK Greeter. The revised steps are given below:

    1. Merge x11-misc/lightdm and x11-misc/lightdm-gtk-greeter.

    # equery u lightdm
    [ Legend : U - final flag setting for installation]
    [        : I - package is installed with flag     ]
    [ Colors : set, unset                             ]
     * Found these USE flags for x11-misc/lightdm-1.18.3:
     U I
     - - audit         : Enable support for Linux audit subsystem using sys-process/audit
     - - gnome         : Add GNOME support
     + + gtk           : Add support for x11-libs/gtk+ (The GIMP Toolkit)
     + + introspection : Add support for GObject based introspection
     - - kde           : Add support for KDE (K Desktop Environment)
     - - qt4           : Add support for the Qt GUI/Application Toolkit version 4.x
     + + qt5           : Add support for the Qt 5 application and UI framework
    
    # equery u lightdm-gtk-greeter
    [ Legend : U - final flag setting for installation]
    [        : I - package is installed with flag     ]
    [ Colors : set, unset                             ]
     * Found these USE flags for x11-misc/lightdm-gtk-greeter-2.0.1-r1:
     U I
     - - branding : Enable Gentoo specific branding
    

    2. Re-merge kde-plasma/plasma-meta with USE="-sddm".

    3. Remove the x11-misc/sddm package and kde-plasma/sddm-kcm package by using the command ‘emerge --ask --depclean‘.

    4. Edit the file /etc/lightdm/lightdm.conf to include the line ‘greeter-session=lightdm-gtk-greeter‘ and the line ‘display-setup-script=/etc/X11/Sessions/plasma‘:

    # grep -v "^#\|^$" /etc/lightdm/lightdm.conf
    [LightDM]
    session-wrapper=/etc/lightdm/Xsession
    [Seat:*]
    greeter-session=lightdm-gtk-greeter
    session-wrapper=/etc/lightdm/Xsession
    display-setup-script=/etc/X11/Sessions/plasma
    [XDMCPServer]
    [VNCServer]
    

    5. Follow the steps in the ‘Boot service’ section of the Gentoo Linux Wiki article ‘LightDM‘.

    6. Create the above-mentioned Bash script /etc/X11/Sessions/plasma containing the following:

    #!/bin/bash
    GPU=`eselect opengl list | grep \* | awk '{ print $2 }'`
    if [ "$GPU" = "nvidia" ]; then
        xrandr --setprovideroutputsource modesetting NVIDIA-0
        xrandr --auto
    fi	
    

    7. Change the background specified in the file /etc/lightdm/lightdm-gtk-greeter.conf to whatever PNG file you want. Also uncomment the line ‘#indicators=‘ and add the indicators you want (see the various comments at the top of the configuration file for the options available). For example:

    # grep -v "^#\|^$" /etc/lightdm/lightdm-gtk-greeter.conf
    [greeter]
    background=/usr/share/backgrounds/mychosenbackground.png
    indicators=~host;~spacer;~clock;~spacer;~language;~power
    

    Furthermore, irrespective of which DM you use, note that there is a bug in KDE Plasma 5 which means users’ avatars are not set up properly, nor displayed correctly, by ‘System Settings’ > ‘User Manager’. I used the procedure below to work around the bug in my installation that uses LightDM:

    1. I created a 96×96 PNG avatar /home/fitzcarraldo/Pictures/fitzcarraldo.png

    2. I edited the file /var/lib/AccountsService/users/fitzcarraldo to contain the following (replace ‘en_GB.utf8‘ with your language)

    [User]
    Language=en_GB.utf8
    XSession=plasma
    SystemAccount=false
    Icon=/var/lib/AccountsService/icons/fitzcarraldo	
    

    3. I made sure that file has 644 permissions

    # ls -la /var/lib/AccountsService/users/fitzcarraldo
    -rw-r--r-- 1 root root 104 Aug  5 16:43 /var/lib/AccountsService/users/fitzcarraldo
    

    4. I copied the avatar to the relevant directory and made sure it has 644 permissions

    # cp /home/fitzcarraldo/Pictures/fitzcarraldo.png /var/lib/AccountsService/icons/fitzcarraldo
    # ls -la /var/lib/AccountsService/icons/fitzcarraldo
    -rw-r--r-- 1 root root 12667 Aug  5 16:23 /var/lib/AccountsService/icons/fitzcarraldo
    

    After rebooting, the desired avatar was displayed on LightDM’s GTK Greeter screen, on the KDE Plasma 5 Lock screen, in ‘System Settings’ > ‘Account Details’ > ‘User Manager’, and at the top of the KDE Plasma 5 Application Launcher menu.

    I recommend not using ‘System Settings’ > ‘Account Details’ > ‘User Manager’ until the bug is squashed, but you can copy the avatars of other users to /var/lib/AccountsService/icons/ and edit the other users’ files in /var/lib/AccountsService/users/ as explained above. I have always used app-admin/superadduser on the command line to add new users, and it has never failed me. So you can add new users and specify their avatars without touching ‘System Settings’ > ‘Account Details’ > ‘User Manager’.

  3. Marcos says:

    Does all that process enable Nvidia’s OpenGL on your system? I’ve followed your steps, but I have had to «eselect opengl set xorg-x11» because I was getting the same blank screen with no desktop, no panel, although many apps work (I was able to open Konsole or Dolphin via shortcuts, but no OpenGL dependent application would load. for example, trying systemsettings5 from Konsole would return:

    Unrecognized OpenGL version
    Unrecognized OpenGL version
    failed to acquire GL context to resolve capabilities, using defaults..
    KActivities: Database connection: “kactivities_db_resources_139924088822720_readonly”
    query_only: QVariant(qlonglong, 1)
    journal_mode: QVariant(QString, “wal”)
    wal_autocheckpoint: QVariant(qlonglong, 100)
    synchronous: QVariant(qlonglong, 0)
    Nothing to load – the client id is empty
    Nothing to load – the client id is empty
    Unrecognized OpenGL version
    Unrecognized OpenGL version
    Unrecognized OpenGL version
    Unrecognized OpenGL version
    QQuickWidget: Failed to make context current
    QQuickWidget::resizeEvent() no OpenGL context
    QQuickWidget: Failed to make context current
    : QML QQuickLayoutAttached: Binding loop detected for property “minimumHeight”
    Unrecognized OpenGL version
    Unrecognized OpenGL version
    QQuickWidget: Failed to make context current
    QQuickWidget::resizeEvent() no OpenGL context
    QQuickWidget: Failed to make context current
    composeAndFlush: makeCurrent() failed
    QQuickWidget: Attempted to render scene with no context
    QQuickWidget: Attempted to render scene with no context

    So, even if I can launch a Plasma session through LightDM, I still get the same problems than when using SDDM. Am I missing anything?

    Thanks.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: