26

Simple Question: Is there a way to resize a Xvfb display?

I tried with RandR but it seems that the RandR extension is not supported by Xvfb. Are there other ways to resize the screen?

Thanks for your help!

Erik
  • 11,944
  • 18
  • 87
  • 126
  • 2
    Related: [Changing Xvfb frame buffer resolution while it's running](http://unix.stackexchange.com/q/295017/21471) – kenorb Nov 24 '16 at 14:42

2 Answers2

28

You can use the server-args command line argument to specify a custom resolution for the virtual frame buffer being created, but this does not change the resolution of an existing virtual frame buffer:

xvfb-run --server-args="-screen 0, 1024x768x24" ...
Robert
  • 5,484
  • 1
  • 22
  • 35
edigu
  • 9,878
  • 5
  • 57
  • 80
  • 1
    How to change existing virtual frame buffer then? – Jezor Jul 10 '16 at 18:03
  • I'm not sure about that. – edigu Jul 10 '16 at 18:19
  • @totaam ah yes, it has been marked as off-topic. In short, run `Xvfb :1 -screen 0 100x100x16 -fbdir /tmp` and you will have `Xvfb_screen0` binary file in `/tmp`. This file, however, does not work same way as `/dev/fb0` and running `sudo fbset -fb /tmp/Xvfb_screen0 -xres 500 -yres 500` gives an error `ioctl FBIOGET_VSCREENINFO: Inappropriate ioctl for device`. Question was: "Is there any way to change running Xvfb server resolution"? – Jezor Nov 20 '19 at 11:43
  • 1
    @Jezor my answer above does just that. Don't use fbset on a vfb, you have to use xrandr. – totaam Nov 21 '19 at 05:07
6

Most distributions now ship a version of Xvfb with randr support. The code was committed in late 2015 vfb: add randr support (v2).

To resize you will first need to define a new mode (you can use tools like gtf to get the modeline definition values), add it to the virtual output, and then you can switch to it.

ie for 1280x1024:

xrandr --newmode "1280x1024"  109.00  1280 1368 1496 1712  1024 1027 1034 1063 -hsync +vsync
xrandr --addmode screen 1280x1024
xrandr -s 1280x1024
totaam
  • 1,306
  • 14
  • 25
  • Hey @totaam - sorry to resurrect this, but I'm trying to follow these steps and the `xrandr --newmode` doesn't seem to have any effect (no output / errors, and no modes added). Is there any way you know of to get more verbose output from the `--newmode` command? More details here if you're curious: https://gitlab.freedesktop.org/xorg/app/xrandr/-/issues/67 – Dave W. Oct 09 '22 at 06:00