HiDPI

From ArchWiki
Revision as of 07:35, 7 December 2017 by Postadelmaga (talk | contribs) (Added info and workaround for KDE Display Scale font bug)
Jump to: navigation, search

KDE

KDE plasma 5 provides excellent support for HiDPI screens out of the box: You can set the correct DPI by #Using KDE system settings.

Alternatives are to use SDDM#DPI settings or the #X Server. However, it seems that Gtk+ applications ignore both SDDM and X settings. You can fix this by creating a custom login session as follows.

Note:

Playing with GDK_SCALE and GDK_DPI_SCALE values can be useful in case you want to tune GTK app scale in KDE without affecting QT app. For example you may want to do not use the Scale value in KDE Display setting as not integer values creates issues with some QT application fonts.

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements. See Help:Style for reference.Tango-edit-clear.png

Reason: Comply with Help:Style#File editing requests (i.e. do not use sed). (Discuss in Talk:HiDPI#)
# cp /usr/share/xsessions/plasma.desktop /usr/share/xsessions/plasma-custom.desktop
# sed -i 's/\/usr\/bin\/startkde/\/usr\/bin\/startkde-custom/g' /usr/share/xsessions/plasma-custom.desktop
# sed -i 's/Plasma/Plasma (custom)/g' /usr/share/xsessions/plasma-custom.desktop

Create /usr/bin/startkde-custom.

Example for a generic 13" 1920x1080 (You may need to adjust these values depending on your display):

#!/bin/bash
## GDK_SCALE only integer values (ex. 1 2 3 )
export GDK_SCALE=1 
## GDK_DPI_SCALE can be non integer (ex. 1.1 1.2 )
export GDK_DPI_SCALE=1.2
export XCURSOR_SIZE=48
/usr/bin/startkde "$@"

Example for a 15" Retina Macbook Pro (The negative dpi scale ensures that the text is sized correctly):

#!/bin/bash
export GDK_SCALE=2
export GDK_DPI_SCALE=-1
export XCURSOR_SIZE=48
/usr/bin/startkde "$@"

Do not forget to ensure that the script can be executed (# chmod +x /usr/bin/startkde-custom). Logout and choose your new custom session (you may need to restart your display manager for it to show up) and GTK+ applications should be scaled correctly.

Using KDE system settings

You can use KDE's settings to fine tune font, icon, and widget scaling. This solution affects both Qt and Gtk+ applications.

To adjust font, widget, and icon scaling together:

  1. System Settings → Display and Monitor → Display Configuration → Scale Display
  2. Drag the slider to the desired size
  3. Restart for the settings to take effect

To adjust only font scaling:

  1. System Settings → Fonts
  2. Check "Force fonts DPI" and adjust the DPI level to the desired value. This setting should take effect immediately for newly started applications. You will have to logout and login for it to take effect on Plasma desktop.

To adjust only icon scaling:

  1. System Settings → Icons → Advanced
  2. Choose the desired icon size for each category listed. This should take effect immediately.

Display Scale not integer bug :

When you use not integer values for Display Scale it causes font render issue in some QT application ( ex. okular ).

A workaround for this is to:

  1. Set the scale value to 1
  2. Adjust your font and icons and use the "Force fonts DPI" ( this affects all apps, also GTK but not create issue with the fonts )
  3. Restart KDE
  4. If required tune the GTK apps using the variables GDK_SCALE/GDK_DPI_SCALE (as described above)

Tray icons with fixed size

If the tray icons are not scaled with the rest of the desktop, the size can be set in the Plasma configuration. System-wide configuration is located in the file /usr/share/plasma/plasmoids/org.kde.plasma.private.systemtray/contents/config/main.xml, where the dimension of icons can be controlled by editing the default value for iconSize (a value of 2 should be fine):

/usr/share/plasma/plasmoids/org.kde.plasma.private.systemtray/contents/config/main.xml
<entry name="iconSize" type="Int">
    <label>Default icon size for the systray icons, it's an enum which values mean, 
           Small, SmallMedium, Medium, Large, Huge, Enormous respectively. On low 
           DPI systems they correspond to 16, 22, 32, 48, 64, 128 pixels. On high
           DPI systems those values would be scaled up, depending on the DPI.</label>                    
    <default>2</default>
</entry>

User configuration is located in the file ~/.config/plasma-org.kde.plasma.desktop-appletsrc. The section containing the settings for the tray bar should look similar to this; if the iconSize field is not present, add it.

~/.config/plasma-org.kde.plasma.desktop-appletsrc
[Containments][47][General]
extraItems=org.kde.plasma.mediacontroller,org.kde.plasma.battery,org.kde.plasma.printmanager,org.kde.plasma.bluetooth,org.kde.plasma.clipboard,org.kde.plasma.notifications,org.kde.plasma.networkmanagement,org.kde.plasma.devicenotifier
hiddenItems=org.kde.ktp-contactlist,org.kde.plasma.battery
knownItems=org.kde.plasma.mediacontroller,org.kde.plasma.battery,org.kde.plasma.printmanager,org.kde.plasma.bluetooth,org.kde.plasma.clipboard,org.kde.plasma.notifications,org.kde.plasma.networkmanagement,org.kde.plasma.devicenotifier
shownItems=org.kde.plasma.notifications,org.kde.plasma.clipboard
iconSize=2