I am using Ubuntu 18.10.
I am trying to create two aliases in my .bashrc for commands to "resdown" and "resup" (i.e. decrease and increase my screen resolution respectively).
The resdown command is as follows, and works just fine:
xrandr --output DP-2 --mode 3840x2160
The issue I have is with resup. When I run the following:
xrandr --output DP-2 --mode 3840x2160
The UI scaling is set back to 100%. I need to change the scaling to 200%, or everything on my 4K display is incredibly small.
I have been experimenting with the "--scale" option for xrandr, but it entirely screws up my display. As such, I am not sure that it is doing what I think it is doing:
xrandr --output DP-2 --mode 3840x2160 --scale 2x2
If I used my second monitor to go back into gnome-control-center, I can set the screen resolution and scaling just fine, and everything goes back to normal. I want, however, to do this from the command line.
Basically - I want to know how to set the "Scale" setting that you see in gnome-control-center (see below) from the command line. How can I do this?:
Tl;Dr:
sed -i -e '/<scale>/ s/1/2/' ~/.config/monitors.xml && sudo systemctl restart gdm
Mutter does listen to some settings in Gsettings, and after looking at the code, there is some legacy gsettings support for deprecated settings like gsettings ui-scaling-factor. For other things, it supports using XML for configuration. You'll probably need to
Alt+F2, r
to restart gnome-shell for settings to apply... or figure out the dbus details from the code.Here is my config for an old monitor... notice the line... easy to sed
I put together the codes above to do 200x. It works on wayland and X, but will log you out. If you can do ALt+F2,
r
, that would obviously be better... I tried doing it with a terminal command and just kept crashing gnome. Might use Robot.js or xdotool to send a restart command... like thisxdotool keydown alt && sleep 1 && xdotool key F2 keyup alt && sleep 1 && xdotool key r && sleep 1 && xdotool key KP_Enter
My full version for X11
swap-res.sh
... this works on an ubuntu keyboard shortcut tooSource: https://gitlab.gnome.org/GNOME/mutter/ (quite literally, leave a star!)
SEO / Similar Questions:
Scaling Gnome login screen on HiDPI display
How do I use Mutter with GNOME Shell?
Changing UI scaling from command line