Offer command line options for monitors.xml management
Expected behaviour
Generate monitors.xml
This is of highest importance.
- "$HOME/.config/monitors.xml" is not automatically generated during the installation of GNU/Linux distributions (Ubuntu 23.10 tested).
- There is no command to generate a default "$HOME/.config/monitors.xml". A script cannot be written that manages the GUI
gnome-control-center display
- Solution:
gnome-control-center display --make-monitors.xml
to generate a default "$HOME/.config/monitors.xml" file. The screen resolution can then be modified (regardless of the values) via Bash:
variable_name="width"; variable_value="1920"; sed -i "s/$variable_name.*$variable_name/$variable_name>$variable_value<\/$variable_name/g" "$HOME/.config/monitors.xml"
variable_name="height"; variable_value="1080"; sed -i "s/$variable_name.*$variable_name/$variable_name>$variable_value<\/$variable_name/g" "$HOME/.config/monitors.xml"
- monitors.xml can then be reused by the GDM display manager:
sudo cp ~/.config/monitors.xml /var/lib/gdm3/.config/monitors.xml
Get data from monitors.xml
The mate-display-properties --get-xrandr-output-config option was introduced in Mate Display Properties 1.24. This version was released in April 2020.
The option was removed in Mate Display Properties 1.26, which was released in October 2021. This is because the mate-display-properties command was updated in this release to use a new backend that does not support this option.
Notes
xrandr will temporarily change the screen resolution with: screen_resolution="1920x1080"; xrandr --output "$(xrandr --listactivemonitors | tail -1 | awk '{ print $NF }')" --mode "$screen_resolution"
Also, it to ~/.bashrc to make it permanently will interfere with "$HOME/.config/monitors.xml" that is generated by mate-display-properties
Actual behaviour
"$HOME/.config/monitors.xml" is generated
Steps to reproduce the behaviour
- Run
gnome-control-center display
. Change the screen resolution.