### [2] How to automatically change the display resolution when the window's dimensions change?
Some desktop environments automatically take care of this out of the box. Gnome in Ubuntu does it automatically, but XFCE doesn't do it for instance.
Here is what to do to solve this issue.
1. If the `~/.local/bin` directory doesn't exist, create it:
```bash
mkdir-p ~/.local/bin/
```
1. Then create the bash script below and save it into `~/.local/bin/update-virt-display`:
Below we desribe what to do to solve this issue. The idea is to execute a script that runs indefinitely. The scripts' purpose is to monitor the display output and whenever a change of resolution is detected, it adjusts the display to the newly detected resolution.
1. As root, create the bash script below and save it into `/usr/local/bin/update-virt-display`:
```bash
#!/bin/bash
...
...
@@ -724,10 +721,11 @@ Here is what to do to solve this issue.
1. Finally, execute the script at the beginning of the session. How to achieve this depends on the window manager being used. For instance, with XFCE go to "Settings Manager" -> "Session and Startup" -> "Application Autostart" and add a new entry with the following details:
| | |
|--- |--- |
| Name | `update-virt-display` |
| Description | Monitor screen resolution changes and update the desktop size accordingly |