Gnome Shell font scaling resetting [duplicate]
I'm using Ubuntu 20.04
with Linux Kernel 5.7.10-050710-generic
and GNOME Shell 3.36.3
.
I have set font scaling factor to 1.25
but lately when I restart while the scaling factor lasts to the UI, it is not applyed to gnome shell.
To make it work again I have to manually reset it to 1.25
again.
Any suggestions?
Solution 1:
I experience this too, with fresh Ubuntu 20.04 installation. I see the root cause of this was found ( https://bugs.launchpad.net/ubuntu/+source/mutter/+bug/1892440 ).
I can offer my workaround: add to autostart a trivial command that explicitly sets the "text scaling factor" after login. This change will be correctly noticed by the GNOME shell, making the GNOME shell text correctly scaled.
To do this, create a file $HOME/.config/autostart/fix-font-scaling.desktop
with this content:
[Desktop Entry]
Name=Fix Font Scaling
GenericName=Fix Font Scaling
Exec=/home/michalis/bin/fix-font-scaling.sh
Terminal=false
Type=Application
StartupNotify=false
X-GNOME-Autostart-enabled=true
Where /home/michalis/bin/
is just an example, it's where I keep the script.
Then make a script /home/michalis/bin/fix-font-scaling.sh
with contents like this:
#!/bin/bash
set -eu
# wait a bit, otherwise the change seems to not be noticed properly
sleep 1s
# change to 1.5 then to 1.25, it seems necessary for GNOME shell to register this "change"
gsettings set org.gnome.desktop.interface text-scaling-factor 1.5
gsettings set org.gnome.desktop.interface text-scaling-factor 1.25
Make it executable (chmod +x /home/michalis/bin/fix-font-scaling.sh
).
And adjust the 1.25 above as needed.
Note that this overrides the text scaling you have set by settings ("Accessibility -> Large Text", or GNOME tweak tool "text scaling").
Note: what does set -eu
do?
It makes writing bash scripts safer, so I learned to use this automatically in all my bash scripts :)
It's a shortcut for set -e
and set -u
.
-
The
set -e
means that a bash script will exit with non-zero status as soon as some command exits with non-zero status. E.g. ifsleep
command fails for any weird reason, then followinggsettings
calls will not be done. Withoutset -e
, bash scripts happily continue their execution, even when something along the way reported failure. -
The
set -u
means that the script fails when you try to use an undefined variable, likeecho ${SOMETHING_UNDEFINED}
. Soset -u
allows to catch errors in the script easier. It has no effect in this particular script that uses no variables :) It's was just my force of habit to use it.
There's a great article discussing this (and some related) bash constructs, to make bash scripts easier to write/debug, on http://redsymbol.net/articles/unofficial-bash-strict-mode/ .