Qubes-Community-Content/docs/customization/dpi-scaling.md

186 lines
6.6 KiB
Markdown
Raw Normal View History

DPI scaling
===========
Qubes OS passes on dom0's screen resolution to VMs (this can be seen in the output of `xrandr`) but doesn't pass on dom0's dpi value. Recent distributions have automatic scaling depending on the screen's resolution (eg. in fedora if the screen resolution is at least 192dpi and the screen height is greater than 1200 pixels) but for a variety of reasons one may have to set a custom dpi scaling value.
Dom0
----
The simplest way to set dpi scaling in dom0 is to use the desktop environment's custom dpi feature:
- Xfce: Qubes Menu → System Tools → Appearance → Fonts tab: Custom DPI setting: `xxx`
- KDE: Qubes Menu → System Settings → Font → Force font dpi: `xxx`
2022-02-17 09:17:52 -05:00
- i3: add `Xft.dpi: xxx` to `/home/user/.Xresources' in dom0
2018-04-15 01:35:07 -04:00
Replace `xxx` with a number that fits your setup and is a multiple of 6, as numbers that aren't sometimes result in annoying rounding errors that cause adjacent bitmap font sizes to not increment and decrement linearly.
### Qubes Applications
Qubes applications (e.g. Qubes Create VM, etc.) don't scale automatically, to solve this issue it is possible to set the `QT_SCALE_FACTOR` variables as described
[here](https://doc.qt.io/qt-6/highdpi.html#qt-scale-factor3). To test these
values first, open a terminal and type:
~~~
QT_SCALE_FACTOR=1.8 qubes-global-settings
~~~
You can try change the values for `QT_SCALE_FACTOR` to your
liking.
Once you confirmed that this is working, you can make these settings permanent
by creating a file `/etc/profile.d/dpi_QT.sh` (in dom0) with
the following content and your own values:
~~~
#!/bin/sh
export QT_SCALE_FACTOR=1.8
~~~
Then make the script executable with
~~~
sudo chmod +x /etc/profile.d/dpi_QT.sh
~~~
And logout and login again to see the results.
VMs
---
2018-04-16 12:01:55 -04:00
The procedure for setting DPI scaling is different depending on whether gnome settings daemon is running or not:
2018-04-16 09:01:45 -04:00
2018-04-16 11:59:15 -04:00
- if the daemon is stopped/not installed, applications honor the `Xft.dpi` [X resource](https://en.wikipedia.org/wiki/X_resources) which we can then use for scaling.
- if the daemon is running (`/usr/libexec/gsd-xsettings` process in Fedora), applications are prevented from using the `Xft.dpi` resource and `dconf` values have to set.
2018-04-16 09:01:45 -04:00
Notes:
2018-04-16 11:59:15 -04:00
- the official `fedora-xx` template has the `gnome-settings-daemon` rpm installed by default while the `fedora-xx-minimal` template doesn't.
2018-04-16 09:08:34 -04:00
- DPI scaling with `xterm` (or any glib apps) requires the use of a xft font:
2018-04-16 09:27:29 -04:00
- for `xterm`, ctrl - right click in the terminal's windows and select 'TrueType Fonts' (make sure you have such fonts installed).
2018-04-16 09:32:22 -04:00
- or more generally, set the `faceName` Xresource, eg.:
`*faceName: DejaVu Sans Mono:size=14:antialias=true`
You may do so temporarily with the `xrdb -merge` command, or permanently in a `Xresources` file (see section below).
2018-04-16 09:01:45 -04:00
2018-04-16 12:01:55 -04:00
### VMs without gnome settings daemon ###
Get the current value of `Xft.dpi`:
~~~
xrdb -query | grep Xft.dpi
~~~
2018-04-15 01:35:07 -04:00
Test with a different dpi value: in a terminal issue the following command and then start an application to check that the menus/fonts' size is increased/decreased; replace '144' with the value set in dom0 (it's possible to set a different value in VMs though):
~~~
echo Xft.dpi: 144 | xrdb -merge
~~~
2018-04-16 11:59:15 -04:00
Once you found a value that fits your setup you'll likely want to permanently set the `Xft.dpi` resource. You can do so on a per-template (system-wide) or per-VM basis:
2018-04-15 01:12:22 -04:00
- add (or modify) `Xft.dpi: xxx` in the TemplateVM's Xresource file (`/etc/X11/Xresources` or `/etc/X11/Xresources/x11-common` for whonix-ws-template).
- or, add `Xft.dpi: xxx` to `$HOME/.Xresources` in each AppVM.
2018-04-15 01:12:22 -04:00
2018-04-16 12:01:55 -04:00
### VMs with gnome settings daemon ###
2018-04-16 09:01:45 -04:00
We'll set the `scaling-factor` and `text-scaling-factor` dconf values in the `org.gnome.desktop.interface` schema.
2018-04-16 09:01:45 -04:00
2018-04-16 11:59:15 -04:00
Get the current values:
~~~
gsettings get org.gnome.desktop.interface scaling-factor
gsettings get org.gnome.desktop.interface text-scaling-factor
~~~
Test with different values; notes:
- windows and menu/fonts should be resized dynamically
- when running the commands below the values will be automatically written to `$HOME/.config/dconf/user`
- replace `2` and `0.75` to suit your needs (`scaling-factor` **must** be an integer though)
~~~
gsettings set org.gnome.desktop.interface scaling-factor 2
gsettings set org.gnome.desktop.interface text-scaling-factor 0.75
~~~
If `gsd-xsettings` is running but nothing happens, examine the output of `dconf dump /`. If needed, reset any `xsettings` override:
~~~
gsettings reset org.gnome.settings-daemon.plugins.xsettings overrides
~~~
2018-04-16 11:59:15 -04:00
To store the dconf values system-wide - eg. when customizing templateVMs - copy the following text into `/etc/dconf/db/local.d/dpi` (replace `2` and `0.75` with your values):
~~~
[org/gnome/desktop/interface]
scaling-factor=uint32 2
text-scaling-factor=0.75
~~~
Then run `dconf update`.
2019-01-10 05:44:28 -05:00
Note: the `scaling-factor` and `text-scaling-factor` values might already be set in an AppVM's user profile, in which case they'll override the system-wide ones. To use system-wide values, reset the user values like so in the AppVM(s):
~~~
gsettings reset org.gnome.desktop.interface scaling-factor
gsettings reset org.gnome.desktop.interface text-scaling-factor
~~~
2018-04-16 12:01:55 -04:00
For more information on setting system-wide dconf values see [this page](https://help.gnome.org/admin/system-admin-guide/stable/dconf-custom-defaults.html.en).
2022-02-17 09:38:18 -05:00
Troubleshooting
===============
2022-02-17 09:20:28 -05:00
2022-02-17 09:38:18 -05:00
Firefox and other GTK3 applications
-----------------------------------
2022-02-17 09:20:28 -05:00
Even when setting the correct dpi values, some applications might have very
small icons or similar elements. This usually happens in Firefox for example.
To mitigate this issue it is possible to set the `GDK_SCALE` and `GDK_DPI_SCALE`
variables as described
[here](https://wiki.archlinux.org/title/HiDPI#GDK_3_(GTK_3). To test these
values first, open a terminal and type:
~~~
export GDK_SCALE=2
export GDK_DPI_SCALE=0.5
firefox
~~~
You can try change the values for `GDK_SCALE` and `GDK_DPI_SCALE` to your
liking, but `GDK_SCALE` needs to be an integer value.
Once you confirmed that this is working, you can make these settings permanent
by creating a file `/etc/profile.d/dpi_GDK.sh` (ideally in the template VM) with
the following content and your own values:
~~~
#!/bin/sh
export GDK_SCALE=2
export GDK_DPI_SCALE=0.5
~~~
Then make the script executable with
~~~
sudo chmod +x /etc/profile.d/dpi_GDK.sh
~~~
Resources
2022-02-17 09:38:18 -05:00
=========
- ARCH Linux HiDPI wiki page: https://wiki.archlinux.org/index.php/HiDPI
- Gnome HiDPI wiki page: https://wiki.gnome.org/HowDoI/HiDpi
- Mozilla DPI-related Font Size Issues on Unix: https://www-archive.mozilla.org/unix/dpi.html
- Related official issue: https://github.com/QubesOS/qubes-issues/issues/1951
2018-04-15 01:25:38 -04:00
`Contributors: @taradiddles`