sundrythoughts
sundrythoughts

Reputation: 1

virtualbox: programmatically change resolution from inside guest

I'm setting up a Linux VM that will be accessed via XRDP. The client user will only have access to the VM through RDP. I want him to be able to resize the guest but I haven't found a way to do that from inside the guest. How does one go about changing the guest resolution from inside the guest? I have guest additions installed but haven't been able to find any utilities that would help.

From the host you can run this: VBoxManage controlvm "Arch Linux" setvideomodehint 1440 900 32

But, like I said earlier, the host will be inaccessible to the user.

Any ideas?

Upvotes: 0

Views: 748

Answers (1)

kronenpj
kronenpj

Reputation: 221

The user should have access to xrandr which will list the available video modes. If the RDP client supports resizing after a connect, this should allow them to see the change immediately. Otherwise the VM should retain the setting after disconnecting and reconnecting. Running xrandr without any arguments will give a list of available resolutions available. Eg:

% xrandr
Screen 0: minimum 640 x 480, current 1280 x 1024, maximum 1280 x 1024
default connected 1280x1024+0+0 0mm x 0mm
   1280x1024       0.0*
   1024x768        0.0
   800x600         0.0
   640x480         0.0

Then supplying a -s n parameter will set the resolution. Eg. xrandr -s 1 will set the resolution to 1024x768 in this example.

You can also add resolutions by using setextradata like this:

VBoxManage setextradata virtualmachine CustomVideoMode1 1120x986x32

Multiple modes / resolutions can be set by incrementing the 1 on the end. Just be sure you have the guest additions installed otherwise this might not work as intended.

Upvotes: 1

Related Questions