Text too small in X Windows when using nvidia-drivers

In an earlier post titled ‘Switching between Intel and NVIDIA graphics processors on a laptop with NVIDIA Optimus hardware running Gentoo Linux‘ I described how I am able to switch between the closed-source NVIDIA video driver and the open-source Intel video driver on a Clevo W230SS laptop with NVIDIA Optimus hardware. This works nicely, but one thing had been niggling me for over a year: the size of the fonts in the Desktop Environment were much smaller when using the NVIDIA driver than when using the Intel driver. I could of course increase the font size via KDE’s ‘System Settings’ > ‘Font’ when using the NVIDIA driver, but then I would have to reduce the font size the same way when using the Intel driver. So I resolved to find a better way, and it turned out all I needed to do was add one line to the Monitor section in xorg.conf to specify the DPI (Dots Per Inch) for the X Screen when using the NVIDIA driver:

Section "Monitor"
    Identifier     "Monitor0"
    Option         "DPMS"
    Option         "DPI" "96 x 96"

You can read more about this in the NVIDIA Accelerated Linux Graphics Driver README and Installation Guide, Appendix B. X Config Options.

As described in my earlier post, I run a script to copy a file I named xorg.conf.nvidia to xorg.conf when I want to use the NVIDIA driver, and another script to copy a file I named xorg.conf.intel to xorg.conf when I want to use the Intel driver. So all I needed to do was add the line Option "DPI" "96 x 96" to the Monitor section in the file xorg.conf.nvidia and run my script to switch to the NVIDIA driver. Problem finally solved.

Office 2007 mime-type problem in KDE Plasma 5

Further to my 2015 post Office 2007 mime-type problem in KDE, another problem opening Excel .xlsm files in Office 2007 with WINE in Gentoo Linux Stable happened to me recently, this time in KDE Plasma 5.5.5. Whenever I clicked on an Excel macro-enabled spreadsheet file myspreadsheet.xlsm in Dolphin, a pop-up window titled ‘Choose Application – Dolphin’ would prompt me to ‘Select the program you want to use to open the file myspreadsheet.xlsm’. When I selected Microsoft Excel 2007 from the ‘Known Applications’ list and ticked ‘Remember application association for all files of type “Excel macro-enabled spreadsheet” (application/vnd.ms-excel.sheet.macroEnabled.12)’, Excel would launch and load the spreadsheet. However, the next time I double-clicked the file, the pop-up window would prompt me again. So I tried setting the file association via ‘System Settings’ > ‘Applications’ > ‘File Associations’. Now, there are three entries under ‘Known Types’: vnd.ms-excel.sheet.macroEnabled.12, vnd.ms-excel.sheet.macroenabled.12 and x-wine-extension-xlsmhtml. However, there was no application listed in the box ‘Application Preference Order’ for vnd.ms-excel.sheet.macroEnabled.12, and, if I added Microsoft Excel 2007 to the list and clicked ‘Apply’, the new entry would disappear immediately.

Unlike the situation described in the above-mentioned post, the mime type for the .xlsm file appeared correct:

$ file myspreadsheet.xlsm
myspreadsheet.xlsm: Microsoft Excel 2007+
$ xdg-mime query filetype myspreadsheet.xlsm

The file /usr/share/mime/subclasses contains ‘macroEnabled‘ rather than ‘macroenabled‘:

$ grep macroenabled /usr/share/mime/subclasses
$ grep macroEnabled /usr/share/mime/subclasses
application/vnd.ms-excel.sheet.binary.macroEnabled.12 application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
application/vnd.ms-excel.addin.macroEnabled.12 application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
application/vnd.ms-powerpoint.slideshow.macroEnabled.12 application/vnd.openxmlformats-officedocument.presentationml.slideshow
application/vnd.ms-excel.sheet.macroEnabled.12 application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
application/vnd.ms-powerpoint.presentation.macroEnabled.12 application/vnd.openxmlformats-officedocument.presentationml.presentation
application/vnd.ms-word.template.macroEnabled.12 application/vnd.openxmlformats-officedocument.wordprocessingml.template
application/vnd.ms-excel.template.macroEnabled.12 application/vnd.openxmlformats-officedocument.spreadsheetml.template
application/vnd.ms-powerpoint.template.macroEnabled.12 application/vnd.openxmlformats-officedocument.presentationml.template
application/vnd.ms-word.document.macroEnabled.12 application/vnd.openxmlformats-officedocument.wordprocessingml.document
application/vnd.ms-powerpoint.slide.macroEnabled.12 application/vnd.openxmlformats-officedocument.presentationml.slide

but the work-around mentioned in my 2015 post (i.e. replacing ‘macroEnabled‘ with ‘macroenabled‘ in the file /usr/share/mime/subclasses) did not fix the latest problem: I was still prompted to choose an application every time I double-clicked on a .xlsm file. So I reverted to the original contents of /usr/share/mime/subclasses (i.e. back to ‘macroEnabled‘) and looked in the directory /usr/share/mime/application/ to see what it contained for Excel spreadsheets:

$ ls -1 /usr/share/mime/application/vnd.ms-excel.sheet.*

As there was no file for vnd.ms-excel.sheet.macroEnabled.12.xml I decided to create one to see if that would solve the problem:

$ sudo cp /usr/share/mime/application/vnd.ms-excel.sheet.macroenabled.12.xml /usr/share/mime/application/vnd.ms-excel.sheet.macroEnabled.12.xml

It did! If I click on a .xlsm file now, Excel 2007 launches and opens the spreadsheet.

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:
GPU=`eselect opengl list | grep \* | awk '{ print $2 }'`
if [ "$GPU" = "nvidia" ]; then
    xrandr --setprovideroutputsource modesetting NVIDIA-0
    xrandr --auto

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.

How to stop the clock in a VirtualBox virtual machine from drifting

I found that the clock in a VirtualBox virtual machine was drifting significantly from real time. As shown below, it is possible to synchronise the clock in a virtual machine to the clock in the host machine. Note that you must have VirtualBox Guest Additions installed in the virtual machine, so, if you have not already done that, do it first.

Issue the commands on the host machine. In the example commands shown below, the virtual machine name is ‘TestVM’. Obviously change the name in the command to whatever it is you have named your virtual machine. The grep commands are simply to check that the required change to the .vbox XML file has occurred.

The setextradata command forces the virtual machine to get its time of day from the host machine by setting GetHostTimeDisabled to zero (0 = enabled, 1 = disabled). The command stores the parameter in the .vbox XML file of the virtual machine, ensuring that it is set every time the virtual machine boots.

The guestproperty command forces the virtual machine to re-synchronise its clock to the host machine every ten seconds (ten thousand milliseconds). The command also stores the parameter in the .vbox XML file of the virtual machine.

user $ VBoxManage setextradata "TestVM"
"VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 0
user $ grep GetHostTimeDisabled $HOME/VirtualBox-VMs/TestVM/TestVM.vbox

user $ VBoxManage guestproperty set "TestVM" "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold" 10000
user $ grep timesync $HOME/VirtualBox-VMs/TestVM/TestVM.vbox