Different display sizes for GUI apps in LXD container

HI all,
I am looking for a recipe/tutorial (if it is possible at all) to make a GUI app in an LXD container believe it is on a different monitor(s) set up. Examples:

  • my physical set up is a single display is 3840x2160
  • container one: run as a two displays, 1920x1080 + 1280x1024, each display being a window that I can move around my physical display
  • container two: run as a single display, 3440x1440
  • container three: run as a single display, 1280x768

use cases:

  • keeping the screen-size small so that games don’t choke FPS on an UHD display
  • preventing obnoxious “full screen” javascript web browser pop-ups
  • convenience of dual display for video editing app that is more convenient to manipulate in 2x full screen than in windowed mode
  • fool web fingerprinting into believing that the user is so poor he cannot afford to upgrade from a 1280x768 display
  • many more…

thanks in advance to the experts out there for your help!


You can affect the dimensions of a X window through several ways.
For example, using xdotool.

Note that if the program you are running is a native X11 application, and has code to check these things, it can figure out the size of your physical display.

If you do not mind losing GPU acceleration, you can create separate X servers on the host (using Xephyr, xpra, etc). By doing so, each one of them will have a fixed size of your choosing. And the application would think that it is running full screen at 1280x768.

Alternatively, if you still do not mind losing GPU acceleration, you can create desktops in each container using X2Go (https://blog.simos.info/how-to-use-the-x2go-remote-desktop-with-lxd-containers/) at specific desktop dimensions.

Update: See below

You could also use Wayland (+XWayland) for at least some of your usecases.
Note: This is usable for both X-Server and Wayland, because Wayland can run on top of an X-Server as well.

This way you can run a seperate wayland server on top of an x-server or wayland-server.
You then have a seperate window in which a small desktop is running (the applications inside the container will then run inside that desktop window).
You can also set the window size:

--width=W , --height=H
Make the default size of each X window *W* x *H* pixels.

The only remaining question is how many nested wayland servers are possible to run at the same time.
But I guess you could try it out :smile:.

For some of your usecases, like using a webbrowser, you could also try a solution @simos already mentioned, because for those you don’t need acceleration.

Thanks for all the interesting pointers. Weather is still too good for outdoor activity this weekend, but I will explore some of the possibilities mentioned on one of the next rainy weekend.

@simos: thanks for your blog and generally amazing and useful information sharing. I will try X2Go, GPU acceleration is not a requirement in all scenarios and actually X2Go seems to be a more convenient “work from home” solution than carrying a laptop around or (redundant) installation/configuration of PCs at the remote locations.

@toby63: thanks for the advanced food for thought. Yes I do want fullscreen windows with lower resolutions, particularly for the gaming / GPU-accelerated scenarios.

I have not considered Wayland yet because I am an XFCE user and to the best of my knowledge XFCE does not support Wayland yet. I understand Wayland is the future, and cannot wait for the future to arrive. It will arrive to my desktop when I will find something that is as light and well behaved as XFCE; or when XFCE, specifically Xubuntu, will be able to run on Wayland.

Just for clarification:
You can run Wayland (more correct: a wayland compositor like weston) on top of the X-Server and on-demand (manual start whenever you want), so you can keep your system as-is (no need to switch to Wayland on the Host or change your desktop environment).
The reasons I recommend Wayland for your scenario are:

  1. it seems to be the only “secure” option to run a display server on top of another display server with gpu acceleration (which is what you want, at least for Games and other “demanding” applications).
    (The alternative would be to use the X-Server directly, but X-Server does not have real measures for access restriction (so all applications can access the windows of other applications), so I don’t recommend that option.)
  2. Wayland can run X-Applications through XWayland (which is an X-Server inside Wayland)
    Including desktop environments, also Xfce (see here for example: https://github.com/marbetschar/tins/issues/16#issuecomment-629694254).
    Though you don't need the desktop environment, because the applications will simply run in the wayland window in a minimal desktop environment.

There are only some things to consider:

  • I mention some things in my article about wayland, including:
    • necessary patches to avoid tearing in XWayland (already included in master branch of Xserver, will be included in the next release of Xserver)
      Note: To avoid confusion: Xwayland is a part of XServer (though it is a seperate package on many distros)
    • and some downsides for nvidia gpu users
  • You will need “RandR” for custom resolutions in fullscreen scenarios, basically I see two methods:

So basically there are three steps:

  1. check for nvidia:
    • if you use an amd gpu, everything is fine
    • if you use an nvidia gpu the situation is difficult:
      • proprietary driver: support for gpu acceleration in xwayland is missing, but patches are WIP
      • nouveau: you need reclocking for your card (for full performance; only a few cards have it in nouveau, afaik) and vulkan is not implemented yet
  2. compile Xserver from master branch to solve problems (tearing, randr etc.).
  3. and then follow the steps of my howto, starting weston with:
    weston --xwayland --fullscreen
    This will give you a fullscreen window, then follow the rest of the guide and start a game (or application) with xrandr to set the resolution.

Offtopic, Regarding Xfce:
I am a former Debian + Xfce user and I switched to Arch Linux + Cinnamon some weeks ago.
It has far better performance imo (with Xfce I had a lot of graphical artifacts, slow response etc.), but similar customizability and look & feel, so thats just a tip from my side :wink:.
Note: Cinnamon also does not support Wayland yet, but as I explained above, this is also not necessary for your usecase.

Also a rolling-release distribution is imo better especially for Gaming, because these distributions have the newest software.