Handle `Error: no DISPLAY environment variable specified` automatically
Closed this issue · 13 comments
Running Firefox in Arch TTY with Wayland, but no X11 and no display manager, gives this error:
$ firefox
Error: no DISPLAY environment variable specified
Running cage firefox
in the same TTY starts Firefox in graphical mode, no problem.
The problem
The problem is to prepend cage to every command that needs graphical mode.
The question
Is it possible to intercept application calls that result in Error: no DISPLAY environment variable specified
message?
And if yes, is it possible to run cage
to handle these calls? Without manually prepending cage
to each command.
EDIT: This is pure Wayland system with no X11.
EDIT2: Rewrite of the explanation.
If cage is compiled with Xwayland support, it will set the DISPLAY
env var for processes started inside it.
If you want to make a process started outside of cage connect to the X11 server started inside of cage, you'll need to set DISPLAY
to the same value as the one set inside cage (note, the value might change).
@emersion I've updated the issue description to clarify it is pure Wayland system with no X11.
Alright, then the same applies to Wayland with the WAYLAND_DISPLAY
env var.
@emersion who produces Error: no DISPLAY environment variable specified
error? I believe I've seen this message with other apps too.
If is it lib or kernel, can it execute cage
instead of showing this message? Because I believe cage
is not started at this point.
@abitrolly, I don't get it. Could you try to be a bit more extensive in your description?
Executing cage firefox
will set the correct environment variables for the Firefox process you are launching, among them WAYLAND_DISPLAY
or even DISPLAY
if Cage supports XWayland and everything is fine to start it.
If you don't start Firefox as a Cage argument, you can set the variables by yourself first.
If you try to add arguments to Firefox on Cage command line, use --
to split Firefox options to Cage ones: cage firefox -- -kiosk
.
@joggee-fr I've rewritten the explanation. Hopefully it makes sense now.
@abitrolly, I think I understand a bit your case.
For me, you can't handle this error but I don't think you need to.
Use -s
option for Cage to enable VT switching. Start Cage in VT7 and go back to VT1 for example. In this VT, export WAYLAND_DISPLAY=wayland-0
. Consequently, when you will start a Wayland client, it will attach to running compositor. Switch to VT7 to see it. Note that Cage primary client can be a simple script doing a sleep infinity
.
Is it what you are looking for?
That doesn't sound like a kiosk use case. :D I would prefer to have only one application active in a single TTY. The same way vim
starts in console and gets exclusive mode.
I gave you one possibility but I don't really know your use case.
Back to the topic of this issue i.e. handling DISPLAY or better WAYLAND_DISPLAY not set in environment, it exists hacky way to do this. But for non-child process of Cage, it is outside of the compositor business.
Closing this as out-of-scope.