Xpra: Ticket #1417: choose display number automatically

On multi-user systems is would help a lot, if Xpra could find a free display number automatically.

Recent X servers as of version 1.13 (Xvfb, too) support the -displayfd <fd> command line option: It will make the X server choose the display itself and write the display number back to the file descriptor <fd>.

exec 6>display.log
Xvfb -displayfd 6


Thu, 19 Jan 2017 04:37:28 GMT - Antoine Martin: status changed; resolution set

xpra has supported this feature for years, see #172

Just use:

xpra start

Thu, 19 Jan 2017 08:18:33 GMT - Jens H. Goebbert:

Thanks! - It seams, that I missed a great feature of Xpra. Why should one ever wants to set the display id manually? Shouldn't this be the default way to use Xpra?

Can Xpra report the display number to stdout, if it was automatically chosen? (eg. "Actual display id is now: localhost:28")

How would you recommend to get the automatically chosen display number if it is needed in a wrapper script? Is there any smarter way in Xpra than something like this:

xpra start --start-child=xterm 2>&1 > /dev/null | grep "Actual log file name is now" | sed 's#.*:##g' | sed 's#.log##g'

Thu, 19 Jan 2017 08:38:21 GMT - Antoine Martin:

Why should one ever wants to set the display id manually?


When starting xpra from external management scripts I guess.


Shouldn't this be the default way to use Xpra?


It is!


Can Xpra report the display number to stdout, if it was automatically chosen?


Do you mean like this: r14822?


How would you recommend to get the automatically chosen display number if it is needed in a wrapper script? Is there any smarter way in Xpra than something like this: ...


I don't know, sorry. Using grep and sed can be brittle. I guess we could add our own "--displayfd" switch. This could be a bit tricky to implement since we normally daemonize and close all file descriptors before we know the display number.. (except stdout / stderr which are kept for the messages that you saw - that's already a special case)


Thu, 19 Jan 2017 08:54:04 GMT - Jens H. Goebbert:

Replying to Antoine Martin:

Shouldn't this be the default way to use Xpra?

It is!

Sorry ... www.xpra.org (Get started with Xpra) and the Wiki made me think, this not mend to be the default usage of Xpra. My fault.


Can Xpra report the display number to stdout, if it was automatically chosen?

Do you mean like this: r14822?

Yes ... great!!


How would you recommend to get the automatically chosen display number if it is needed in a wrapper script? Is there any smarter way in Xpra than something like this: ...


I don't know, sorry. Using grep and sed can be brittle. I guess we could add our own "--displayfd" switch. This could be a bit tricky to implement since we normally daemonize and close all file descriptors before we know the display number.. (except stdout / stderr which are kept for the messages that you saw - that's already a special case)

Yes ... great!!


Thu, 19 Jan 2017 12:07:10 GMT - Jens H. Goebbert:

I tested r14822 and it is just doing, what I was looking for. Thanks.

Can you add this feature to the 1.0.x branch, too?


Thu, 19 Jan 2017 12:09:08 GMT - Antoine Martin:

It's been scheduled: wiki/Versions/PendingFixes


Sat, 23 Jan 2021 05:23:45 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/1417