Sunday, November 3, 2019

Change font DPI in KDE from a script

The following script works in Kubuntu 19.10:
#!/bin/bash
dpi=$1
re='^[0-9]+$'
if ! [[ $dpi =~ $re ]] ; then
   echo "error: Not a number" $dpi >&2; exit 1
fi
sed --in-place "s/forceFontDPI=.*/forceFontDPI=$dpi/" \

   $HOME/.config/kcmfonts
xrdb -edit /tmp/.Xresources
sed --in-place "s/Xft.dpi:.*/Xft.dpi:   $dpi/" /tmp/.Xresources
xrdb -load /tmp/.Xresources
dbus-send --session --type=signal /KDEPlatformTheme \

   org.kde.KDEPlatformTheme.refreshFonts

For older versions of Kubuntu the last command (dbus-send ...) was not necessary.