Tutorial: Create Shortcuts to Scale Display Up/Down

Using @Kyle_Rankin’s Scale-the-Screen app from the early amber days as a reference, I created the following shortcuts for quickly changing the display resolution on the fly. (I used 1.5 and 2.0 as resolutions.)

The wlr-randr package that Kyle had to build from source is now packaged for PureOS, so that made it easy for me. You’ll have to install wlr-randr before proceeding with the following.

1 - Starting in the home folder, create 1.5_Scale.desktop and paste the following into .local/share/applications:

[Desktop Entry]
Name=1.5_Scale
Exec=gnome-terminal -x bash -c "wlr-randr --output DSI-1 --scale 1.5"
StartupNotify=true
Terminal=false
Type=Application
Categories=Utilities;
Icon=/home/purism/.local/share/icons/1.5_Scale.png

You can use a different resolution if you prefer; just make sure all occurrences of the name match, for the application, command, and icon.

2 - For an easy return to the default 2.0 resolution, create 2.0_Scale.desktop in .local/share/applications and paste the following:

[Desktop Entry]
Name=2.0_Scale
Exec=gnome-terminal -x bash -c "wlr-randr --output DSI-1 --scale 2"
StartupNotify=true
Terminal=false
Type=Application
Categories=Utilities;
Icon=/home/purism/.local/share/icons/2.0_Scale.png

3 - For the icons, find some free clipart, or draw your own. Then paste them into .local/share/icons.

I made these:
1.5_Scale

2.0_Scale

The launchers will appear on the home screen, probably at the top, since they start with digits. You could also long-press them to add them to the favorites section at the very top.

These makes it easier to select favored resolutions directly, without having to delve into the Settings app.

5 Likes

Launching 1.5_Scale:


Launching 2.0_Scale:

3 Likes

By the way, if you install the latest phosh-mobile-settings package, you can set per-application auto-scaling with a GUI.

7 Likes

Thanks for the script, is squeekboard still scaling as well? Will this last a reboot?

I’m making one to switch off the phone display when plugged to an external monitor, but I’ve got problems when switching it back to normal.

Yes, unfortunately. And no, it does not persist.

That is indeed sweet. Thanks. I’ll post some screenshots.

See screenshots:


@Kyle_Rankin, @guido.gunther, it’s not clear to me how to add a per-app setting. Can you clarify?

1 Like

Launch the app, open phosh-mobile-settings, open the Compositor menu and you should see a list of running applications. Toggle the slider for the application that you want to auto-scale.

4 Likes

Excellent. Thanks.

Changing the settings in phoc.ini doesn’t work either, it doesn’t start phosh for some reason after restarting.

I just noticed that adding my 1.5_Scale app to the startup applications (- I used Tweaks to add it -) causes the phone to switch automatically to 1.5 scale shortly after power on.

2 Likes

I made a script to switch from scale to scale with only one shortcut

Here, the icon I made for it, put it in your pictures folder
zoom-in-out

Here, the script I made, put it into /home/purism/ChangeScale.sh, or wherever ou want :

#!/bin/bash

[ ! -e /usr/bin/wlr-randr ] && echo -e "\e[31mError\e[0m: wlr-randr is missing\n==> sudo apt install wlr-randr" && exit 1

list_scale="1.25 2 1.75"
output="DSI-1"

current_scale=$(wlr-randr --output "${output}" | grep 'Scale:' | awk '{ print $2 }')

next_scale=${list_scale%% *}
flg_found=0
for scale in ${list_scale} ; do
    if [ $flg_found -eq 0 ] ; then
        len=${#scale}
        [ "${scale}" == "${current_scale:0:$len}" ] && flg_found=1
        continue
    fi
    next_scale=${scale}
    break;
done

echo "Change to scale : ${next_scale}"
wlr-randr --output "${output}" --scale "${next_scale}"
  • First click change to 125% (1.25), second click to 200% (2) third click to 175% (1.75), fourth click is back to first, but it depends on what is set in the variable list_scale
  • You can change the content of the variable list_scale at the beginning of the script to your wanted scale list loop
    you can have only one scale number set, or as many as you want in the list
  • Don’t forget to add execution right to the file : chmod +x ChangeScale.sh

Here, the shortcut, put in into ~/.local/share/applications/ChangeScale.desktop :

[Desktop Entry]
Name=ChangeScale
Exec=/home/purism/ChangeScale.sh
StartupNotify=false
Terminal=false
Type=Application
Categories=Utility;Settings;
X-Purism-FormFactor=Workstation;Mobile;
Icon=/home/purism/path/to/Icons/zoom-in-out.png
  • Don’t forget to change the directory of the icon in the last line of the shortcut, or the path of the script in the Exec line if you changed it
3 Likes

Nice! Thanks.

hum… this is annoying
When you have no app launched and you use my icon, it’s “opening” an empty window
It’s probably something to change/add in the .desktop … any idea ?

This tends to happen when a file name used in the .desktop doesn’t exactly match the indicated file name, e.g. capitalization, location, etc.

I’m not qualified to examine… or understand… the script itself, unfortunately.

Pardon my ignorance, but what does this mean?

When you create a file, you usually have read and write permissions/rights
chmod is a tool to modify the permissions on a file
The option +x add execution rights, which means you allow the file to act like an application
If you don’t add right, the script will not do anything, and the system will tell you : permission denied (when executed in a terminal)

1 Like

I get this in the gnome-terminal when I use the shortcut.

EDIT: Obsolete. Disregard

I don’t know what you did there , nor where you put the -x option
There is nothing to do with gtk.css, here…
Every block of code I shared previously are meant to be put inside 2 different files with the extensions ‘.sh’ (for the script file) or ‘.desktop’ (for the shortcut file)
chmod is a tool to be used in the terminal, to set the permission on the script file I proposed previously
And the shortcut file, is suppose to be placed in ~/.local/share/applications/ without any permission modification (I added the file name in my previous post)

I did everything just like you said and that is what shows up for a brief moment in gnome-terminal and the scale does not change.:man_shrugging:

EDIT: I did not do everything you said, I used a different command in the shortcut, But it still does not work after I fixed it.

Ok this is more complex than expected
This topic is about scaling up/down the display scale

So I created an other topic about your problem, go over here to try and solve it: