This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Script scale changing

Tags: hidpi, scale, scaling, script hidpi, scale, scaling, script hidpi, scale, scaling, script
(comma "," separated)
User avatar
jbouter
Registered Member
Posts
15
Karma
0
OS

Script scale changing

Mon Feb 03, 2020 10:11 pm
Hi all,

I often change between just using my laptop (XPS 15 9570) with HiDPI, and using an external monitor. Every time I switch, this means I have to change the following settings:
  • Global Scale (under Display and Monitor)
  • Cursor Size (under Cursors)
  • Font DPI (Under Fonts)

Now I've been able to mostly script this, by changing the desired settings and using find and diff to see what values have changed in certain files. I have this far come up with the following:

Code: Select all
#!/bin/bash

LATTE_CONFIG="$HOME/.config/latte/Plasma.layout.latte"
CURSOR_CONFIG="$HOME/.config/kcminputrc"
CURSOR_STARTUP_CONFIG="$HOME/.config/startupconfig"
SCALING_CONFIG="$HOME/.config/kdeglobals"
FONT_CONFIG="$HOME/.config/kcmfonts"


# Check if $1 has been given
if [ -z ${1+x} ]; then
  echo "Usage: $(basename "$0") [external|laptop]"
  exit 1
fi

if [ "$1" = "external" ]; then
  # Settings for external display
  LATTE_SIZE="48"
  CURSOR_SIZE="24"
  SCALING="1"
  FORCE_FONT_DPI="96"
  SCREEN_SCALE_FACTORS="eDP-1=1;DP-1=1;DP-2=1;"
elif [ "$1" = "laptop" ]; then
  # Settings for laptop (hidpi) display
  LATTE_SIZE="86"
  CURSOR_SIZE="48"
  SCALING="2"
  FORCE_FONT_DPI="192"
  ScreenScaleFactors="eDP-1=2;DP-1=2;DP-2=2;DP-3=2;"
else
  # If $1 is not either 'laptop' or 'external', throw an error
  echo "$1 is not a recognised option"
  echo "Usage: $(basename "$0") [external|laptop]"
  exit 1
fi

# Configure latte dock
sed -i "s/iconSize=[0-9]\+/iconSize=$LATTE_SIZE/" $LATTE_CONFIG

# Configure cursor scaling
kwriteconfig5 --file $CURSOR_CONFIG --group "Mouse" --key "cursorSize" "$CURSOR_SIZE"
sed -i "s/kcminputrc_mouse_cursorsize=[0-9]\+/kcminputrc_mouse_cursorsize=$CURSOR_SIZE/" $CURSOR_STARTUP_CONFIG

# Configure display scaling
kwriteconfig5 --file $SCALING_CONFIG --group "KScreen" --key "ScaleFactor" "$SCALING"
kwriteconfig5 --file $SCALING_CONFIG --group "KScreen" --key "ScreenScaleFactors" "$SCREEN_SCALE_FACTORS"
kwriteconfig5 --file $FONT_CONFIG --group "General" --key "forceFontDPI" "$FORCE_FONT_DPI"

echo "Settings changed, please log out and back in"


However, this does not change one minor setting, being icon sizes in some applications, such as kmail. And I can't, for the life of me, figure out what setting I'm missing. Can anyone shed some light on what config changes are being applied regarding icon sizes? It could very well be that this is only applied when the plasma session ends.

Thanks in advance!

EDIT: an example of this effect in Dolphin has been uploaded to imgur
User avatar
jbouter
Registered Member
Posts
15
Karma
0
OS

Re: Script scale changing  Topic is solved

Wed Feb 05, 2020 3:02 pm
Apparently, I had a small typo in my script. The variable SCREEN_SCALE_FACTOR was incorrectly set to Screen_Scale_Factor when the laptop option was chosen. I have fixed, and therefore resolved, the issue.
User avatar
saLOUtion
Registered Member
Posts
4
Karma
0
OS

Re: Script scale changing

Mon Dec 21, 2020 9:10 pm
I face the same problem.

I use opensuse and when I use the Plasma Wayland session in the login screen (either full or normal), the scaling settings are just perfect without any manual intervention. The Wayland session is just very unstable and aspects like screensharing etc. do not work yet or require at least much extra configuration.

I thought about the following setup:

  • copy the definition of the normal Plasma X11 session and call it e.g. Plasma X11-HiDPI
  • add to the definition of HiDPI environment variables to adapt the scales (taken from your script for instance)
  • use the choice of the login manager to switch between these two profiles HiDPI and normal DPI

Useful resources would be:



Bookmarks



Who is online

Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]