Comment 2 for bug 908944

Revision history for this message
Ryan Thompson (rct86) wrote :

If I'm reading it correctly, it looks like the implementation of byobu-reconnect-sockets only works at the shell level. So it would only fix the environment variables in the current shell, and would need to be re-run in every existing shell and every newly-created shell window as well.

The script that I wrote actually updates the terminal multiplexer's (screen's or tmux's) values for the environment variables in question, so that any newly-spawned shell windows inside the multiplexer will inherit the new value. Obviously, existing windows are unaffected, but one could write a shell function to query the multiplexer for the required environment variables and set them in the shell.

Basically, I'm thinking that what is required are a pair of scripts "byobu-sendenv" and "byobu-getenv". The first would be used outside of the multiplexer like:

$ byobu-sendenv DISPLAY

and would send the current value of DISPLAY to byobu's multiplexer. The second would be used inside byobu in a running shell like:

$ DISPLAY=$(byobu-getenv DISPLAY)

will send any environment variable you tell it to send to the session of your choice. Once those two support scripts are in place, the byobu launch process would go something like this:

1. Check if byobu is running. If not, start it in the background, and don't connect to it yet.
2. byobu-sendenv DISPLAY SESSION_MANAGER DBUS_SESSION_BUS_ADDRESS ...
3. Connect to the session, which now has the correct environment variables set
4. Define a shell alias or keyboard shortcut to propogate the new values of these variables to the shell in the current window

The rest is simply knowing which environment variables to send. For the X11 session, obviously you need to send DISPLAY, but there may be others as well that I don't know about. You would probably have a config file somewhere telling byobu which environment variables should be handled in this way, which defaults to SESSION_MANAGER, DBUS_SESSION_BUS_ADDRESS, DISPLAY, etc.

Anyway, feel free to use my script for testing purposes, but it probably has too many dependencies to actually include in byobu. That's why you can use the --verbose option to have it tell you what it's doing.

I might get around to implementing it myself eventually, but it's not high on my list of priorities.