Change the display scaling on the fly

Solution 1:

This answer of @rubo77 provides great solution of a similar question. I will elaborate it within the final part to achieve this result.

You can find out where the setting is changed if you open a terminal:

gsettings list-recursively > /tmp/before
echo 'Now unity-control-center should open. Please change the scaling in "Displays" and close.'
unity-control-center
gsettings list-recursively > /tmp/after
diff /tmp/before /tmp/after | grep '[>|<]'

Copy and paste the above lines into a terminal. These command will create two temp files - before and after the change of the scale factor. Press Enter after you close Unity Control Center to execute the last line, that will compare these two temp files.

In my system when I change the scale factor from 1 to 1.5 the output of the above is:

< org.gnome.desktop.interface text-scaling-factor 1.0
> org.gnome.desktop.interface text-scaling-factor 1.5
< org.gnome.desktop.interface cursor-size 24
> org.gnome.desktop.interface cursor-size 36
< com.ubuntu.user-interface scale-factor {'VGA-1': 8, 'HDMI-0': 8, 'HDMI-1': 8}
> com.ubuntu.user-interface scale-factor {'VGA-1': 8, 'HDMI-0': 8, 'HDMI-1': 12}

So the new values are:

> org.gnome.desktop.interface text-scaling-factor 1.5
> org.gnome.desktop.interface cursor-size 36
> com.ubuntu.user-interface scale-factor {'VGA-1': 8, 'HDMI-0': 8, 'HDMI-1': 12}

I've recorded the values when the scaling factor is 1, 1.25 and 1.5.

These values can be changed through the command line by the command gsettings set. So, according to the original answer, I've created a script, called setscalefactor and placed in /usr/local/bin/, thus it will be available as shell command:

sudo touch /usr/local/bin/setscalefactor
sudo chmod +x /usr/local/bin/setscalefactor
sudo nano /usr/local/bin/setscalefactor

The content of my script is:

#!/bin/bash

if [ -z "${1}" ] || [ "$1" == "1" ] || [ "$1" == "1.0" ]; then
    # set scaling to 1.0
    gsettings set org.gnome.desktop.interface text-scaling-factor 1.0
    gsettings set org.gnome.desktop.interface cursor-size 24
    gsettings set com.ubuntu.user-interface scale-factor "{'VGA-1': 8, 'HDMI-0': 8, 'HDMI-1': 8}"
    echo "Set Scale factor: 1.0"; notify-send "Scale Factor" "1.0"
elif [ "$1" == "1.25" ]; then
    # set scaling to 1.25
    gsettings set org.gnome.desktop.interface text-scaling-factor 1.25
    gsettings set org.gnome.desktop.interface cursor-size 30
    gsettings set com.ubuntu.user-interface scale-factor "{'VGA-1': 8, 'HDMI-0': 8, 'HDMI-1': 10}"
    echo "Set Scale factor: 1.25"; notify-send "Scale Factor" "1.25"
elif [ "$1" == "1.5" ]; then
    # set scaling to 1.5
    gsettings set org.gnome.desktop.interface text-scaling-factor 1.5
    gsettings set org.gnome.desktop.interface cursor-size 36
    gsettings set com.ubuntu.user-interface scale-factor "{'VGA-1': 8, 'HDMI-0': 8, 'HDMI-1': 12}"
    echo "Set Scale factor: 1.5"; notify-send "Scale Factor" "1.5"
else
    echo "ERROR: Something went wrong!"; notify-send "Scale Factor" "ERROR: Something went wrong!"
fi

exit
  • Copy the above content and use in nano: Shift+Insert for paste; Ctrl+O and Enter for save; Ctrl+X for exit.
  • Replace the content after gsettings set with the values from your system!
  • Please note the quote marks: "{'VGA-1': ...}".

Now setscalefactor is available as shell command and can handle 1.0, 1.25 and 1.5 as arguments, also when it is executed without an argument it will sale to 1. The script will print and some status messages.

Next step is to create this scrip accessible via shortcut key combination. Go to: Unity Control Center (System Settings) > Keyboard > Shortcuts > Custom Shortcuts. Then create your custom shortcuts, like as the image:

enter image description here

Solution 2:

You have to take a look at xrandr. I say it's the tool of choice.

Edit: xrandr --output "output_name" --scale 0.9x0.9

See more examples with: man xrandr

Solution 3:

Use below command to check the display Pannel interface name :

xrandr

Then to scale :

xrandr --output HDMI-1-1 --scale 1x1

here HDMI-1-1 is my display pannel interface as i am connected with my second display through a hdmi port.

enter image description here