2

I'm looking for a keyboard shortcut or a CLI instruction to change the display scale on the fly. Seems there's nothing in compiz-config manager to handle this?

display scale settings

  • Same askubuntu.com/questions/878023/… but no answer yet. I'll pm Jacob ;-) – Rinzwind Sep 12 '17 at 9:37
  • @Rinzwind done :) will polish the answer, I am in a hurry :) – Jacob Vlijm Sep 12 '17 at 10:21
  • @Rinzwind ooops, wrong scaling, he meant display. Will edit later, no time atm... – Jacob Vlijm Sep 12 '17 at 10:53
1

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

  • 1
    @pa4080 xrandr --output DP-2 --scale 0.9x0.9 scales your screenj output ... – Soren A Sep 12 '17 at 13:57
  • 1
    @SorenA Can you post an answer about that? This answer really doesn't say how to solve the problem, your comment isn't all that visible right now to people who may benefit from it, and I suspect this answer may end up being deleted because it's extremely vague and doesn't really give a solution. – Eliah Kagan Sep 12 '17 at 21:34
  • Sometimes I get "X Error of failed request: BadMatch (invalid parameter attributes)", and only a section of the display is illuminated. But setting a different scale flushes that error. – Qeebrato Sep 13 '17 at 5:53
7

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.