Solution for apps that don't scale on HiDPI displays
As olivierb2 pointed out there is no simple, global way to accomplish this. However, I did find a way to perform window scaling on a per-app basis that works very well, but not for all applications.
I found a script called run_scaled that acts as a front end for xpra, which is like screen for X. It basically sets up a second X server scaled to whatever you choose, runs your app, and then forwards it to your primary display. In order to use it you need to install some deps:
sudo apt-get install xpra winswitch xvfb
Install it:
curl "https://raw.githubusercontent.com/kaueraal/run_scaled/master/run_scaled" > ~/.local/bin/run_scaled
chmod +x ~/.local/bin/run_scaled
And after that on a new shell you run your app like so:
run_scaled someapp
If you test your app(s) that you need scaled and it works you can make it a little more user friendly by copying the script to somewhere in your path and editing the .desktop file for your app so it will launch scaled from your DE.
The downside is that this doesn't work with every app. It seemed to work fine for all of the FOSS apps I tried, but non-free apps like Steam and HipChat didn't work. Not a perfect solution, but it can help in a pinch.
Neither Unity nor GNOME supports HiDPI very well yet, but this will improve soon. You can improve useability by just increasing the size of the fonts using to unity-tweak-tool. Open Fonts in the Appearance section, and adjust the Text scaling factor.
Firefox don't take any notice of Unity tweak settings, so you have to configure it manually. Just open it, type about:config in the URL and set parameter layout.css.devPixelsPerPx to the same value that you defined in Fonts.
As @Adam Drew recommends, use run_scaled
.
On Ubuntu 20.04 LTS install:
sudo apt install xvfb xpra xrandr
Then download run_scaled
script from this zip and put it in the /usr/local/bin
directory.
Then to launch your program, do for example
run_scaled ./soapui.sh
It works very well on Java Swing apps that don't scale naturally.
For individual applications that use Qt5, you just need to edit the .desktop
file. I will give you an example with a snap application like OpenSCAD.
-
Go to
/var/lib/snapd/desktop/applications
. -
Find your
.desktop
application, in this caseopenscad_openscad.desktop
. -
Edit the file (with
sudo
) and find the lineExec=...
. In our case the line is:Exec=env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/openscad_openscad.desktop /snap/bin/openscad %f
and you have to change it to:
Exec=env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/openscad_openscad.desktop QT_SCALE_FACTOR=2.5 /snap/bin/openscad %f
Note that
QT_SCALE_FACTOR=2.5
was added. Adjust the value ofQT_SCALE_FACTOR
to one you're comfortable with. -
Save your file.
-
Restart your application.