DISPLAY update with ssh and byobu

I have the following scenario:

On my work computer (A), I open a byobu (tmux) session.

Inside byobu, I open several terminals. Some are local to (A), while others are ssh on another machine (B).

I go home and from my home computer (C) I ssh to (A), ran "byobu" and found all my sessions at (A) or (B).

This works great except for launching X11 applications. I don't leave the X11 application running when I change computers, but just running "xclock" sometimes works and sometimes it doesn't ("can't connect to X server localhost: n.0").

I understand that it depends on the variable DISPLAY

and that it will be configured so that X11 will connect to the computer where I ran "byobu" last, before creating a session inside byobu, and it could be (A) or (C). My problem is that often I don't know how to fix a session that no longer works. Sometimes I can just open another session (another tab in byobu) and use the value $DISPLAY

in other sessions, but this only works as long as the new session is open, not always. In other cases, I was able to disconnect byobu (F6), reconnect it (run "byobu") and open a new ssh connection (B) and then work, but not the existing sessions.

I have read some docs like SSH, X11 Forwarding and terminal muxers, or How to get tmux X display back? but it is not clear to me how they apply (if any) to my situation. For example, the code of the .bashrc

first if it is in (A), (B) or (C)?


source to share

All Articles