Qt App HiDPI Scaling in Cinnamon

Please post suggestions for improvement of Cinnamon on:
https://github.com/linuxmint/Cinnamon
Post Reply
jman47
Level 1
Level 1
Posts: 10
Joined: Wed Mar 22, 2017 8:02 pm

Qt App HiDPI Scaling in Cinnamon

Post by jman47 »

I'm hoping someone on the forum can help me with this problem:

I have a laptop that has a 4K, HiDPI screen resolution (3200x18000), running Linux Mint 18.1 Cinnamon. When I first installed Mint, I went into the Mint "General" settings and changed the Desktop Scaling to "Double (Hi-DPI)" and that scaled up a lot of the applications on the screen, making them readable again. My problem is that Qt (I believe they're all Qt5) apps, including many I rely upon (like Alfred, Gnome-Do, Master PDF Editor 4, and the list goes on and on...), do not accept Cinnamon's scaling command and are all tiny and unreadable on the screen. Does anyone know how best to force QT apps to scale up so that they are at least legible on a Hi-DPI screen?

I have done a lot of searching and found a few mentions of folks who have perhaps achieved this, but not being a programmer (a Linux novice) I'm not sure how get this working. A few places I looked suggested creating a startup file to force Qt5 apps to scale, and I followed the directions but could not get any of this to work on my machine:

http://seb.mamessier.com/dell-xps-15-9550-ubuntu-16-04/
http://hgdev.co/quick-tip-4-properly-sc ... -displays/

Does anyone have suggestions or similar issues with hidpi scaling of Qt5 apps in Mint 18.1? Is this an issue that is unfixable currently on this version of Mint? I would appreciate any suggestions, thanks! :D

s.lamoureux
Level 1
Level 1
Posts: 7
Joined: Tue Jan 31, 2012 8:00 pm

Re: Qt App HiDPI Scaling in Cinnamon

Post by s.lamoureux »

Did you find a solution to this? I have the same problem.

Namf_Mint
Level 1
Level 1
Posts: 20
Joined: Fri Apr 28, 2017 9:03 pm

Re: Qt App HiDPI Scaling in Cinnamon

Post by Namf_Mint »

I have a solution to this.

1) Appending the following to `/etc/profile`:

Code: Select all

# ** To theme QT apps **
QT_QPA_PLATFORMTHEME=qt5ct
unset QT_STYLE_OVERRIDE 
2) Optionally, install qt5ct via `sudo apt install qt5ct`, run it via `qt5ct` in terminal or by using e.g. MintMenu to find 'Qt5 settings'. Then play around with the options you'll see.

However, I find that, strangely and maddeningly, QT applications will revert at random times to the low-DPI setting. Solution:

3) create the following script, mark it executable, put it somewhere, and run it whenever you have the problem. Getting it to run automatically at scheduled intervals is, though, proving tricky. Until I/someone works out how to do that (via a method like this), you can create an icon for the script and put it on your desktop, or else create a bash alias for it - e.g. the alias 'dpi' - and then you can run it by typing 'dpi' in a terminal.

Code: Select all

!/bin/sh
# NAME		fixDPI
# NEEDS		dash
# NEEDS		To run as the user with the display.
# NEEDS		msg library
# NB		At present this script does not work via 'cron'.

set -o nounset
export LC_ALL=C 									# Speeds up esp. grep, by confining it to ASCII.

readonly DPI_KEY='org.cinnamon.desktop.interface'
readonly DPI_LEAF='scaling-factor' 					# There's 'text-scaling-factor' too but seems wrong key.
readonly VALUE_DESIRED='2'
readonly FIX_ALWAYS=0								# '0' for yes = rewrite DPI value even if seems OK.

central ()
{
	VALUE_CURRENT=$(gsettings get "$DPI_KEY" "$DPI_LEAF" | gawk '{print $2;}')
	if [ "$FIX_ALWAYS" -eq 0 ] || [ "$VALUE_CURRENT" -ne "$VALUE_DESIRED" ] ; then
		gsettings set "$DPI_KEY" "$DPI_LEAF" "$VALUE_DESIRED"
	fi
	return 0
}

main ()
{
	central && return 0
	return 1
}

main && exit 0
# Else ..
exit 1

# EOF
I am afraid that the code doesn't report on what it is doing. (It did, but to do so it made use of a library of mine, and including that library here was too involved.)

Namf_Mint
Level 1
Level 1
Posts: 20
Joined: Fri Apr 28, 2017 9:03 pm

Re: Qt App HiDPI Scaling in Cinnamon

Post by Namf_Mint »

OK; I think I've got the cron version working, i.e. can make the computer run the fix every so-many minutes. It's a bit involved, though; post here if you want the details.

Post Reply

Return to “Cinnamon”