Knowledge Base : Resize desktop (SunRay)

resize desktop (SunRay)
Starting from SRSS 4.1, the Sun Ray Xnewt X server supports the XRandR extension, which allows resizing your desktop while the session is running. This is particularly useful, if you often hotdeskamong Sun Ray DTUs with monitors of different sizes.

Bob even has created a utfit script, which you can use automatically fit your desktop size to the new screen size on hotdesk (needs to be run via utaction on connect).

But the set of sizes any given Sun Ray session can be resized to is limited. And this selection of sizes doesn’t really have anything to do with the currently used Sun Ray and its monitor. If the monitor is small, you may be able to something larger than your monitor and will get scan+pan behavior. If the monitor is large, its size may simply not be available. Instead the sizes that are offered depend on the initial size of your desktop – or more precisely the size of the X server canvas.

When a Sun Ray Xnewt X server is started, it creates a frame buffer that best fits the display of the currently connected DTU. Only if this monitor is very small, a certain minimum size will be reserved. This size is then seen as the initial size of the desktop. As the frame buffer can’t be grown later, this size then becomes the limit for future resizing: you can shrink your desktop and enlarge it again, but only up to the original size. XrandR will offer you a set of standard sizes, but these must be smaller than the starting size in both dimensions.

This is particularly troublesome, if you frequently move between screens where neither is smaller than the other in both dimensions. Myself I usually use a 1600×1200 20,1″ monitor at work and a 22″ 1680×1050 monitor at home. Now if I start my session at work (1600×1200), I can’t resize it to fit my home screen, as 1680px is wider than the frame buffer. But if the session is started at 1680×1050, then I can’t resize for my work screen either, as 1200px is taller than the 1050px frame buffer

utxconfig to the rescue
To solve this problem, you can control the size of the X server canvas using the utxconfigcommand. If you specify a resolution (i.e. a size), a newly started X server will create a frame buffer that can hold this size. In my case, I used

$ utxconfig -r 1680×1200
to specify an odd size, which fits no real monitor exactly. The important property of this choice is that it is at least as large as the pixes dimensions of all the monitor I regularly use. After issuing this command and getting a new X server, I can see that XrandR now allows me to resize my desktop to all the sizes I need:
$ xrandr

SZ: Pixels Physical Refresh
0 640 x 480 ( 180mm x 135mm )
1 800 x 600 ( 225mm x 169mm )
2 1024 x 768 ( 288mm x 216mm )
3 1152 x 900 ( 325mm x 254mm )
4 1280 x 1024 ( 361mm x 289mm )
5 1400 x 1050 ( 395mm x 296mm )
6 1440 x 900 ( 406mm x 254mm )
7 1600 x 1024 ( 451mm x 289mm )
*8 1600 x 1200 ( 451mm x 339mm )
9 1680 x 1050 ( 474mm x 296mm )
10 1680 x 1200 ( 474mm x 339mm )
Current rotation – normal
Current reflection – none
Rotations possible – normal
Reflections possible – none

I need to adjust the size right after initial login, but the utfit script will do even that automatically. And the benefit is well worth the tiny effort anyhow.
Update: the utxconfig command binds the chosen size to your token and stores it in the Sun Ray Data Store. Thus the command needs to be run only once within a failover group. The setting applies on all servers of the group and stays active until you run utxconfig again to change it. But if you occasionally use multiple tokens, you have to set up the session size separately for each one.