10

At work, I have a desktop with a monitor and a few running tmux sessions. At home, I frequently ssh into that desktop and enter my running tmux sessions. When I ssh from home, I do not want to use X11, so I do not use the -X flag. When I go back to work (after ssh'ing from home) and use those tmux sessions on desktop, I can no longer do anything that would spawn a GUI. I can't open files in evince. When I try use matplotlib, I get a : cannot connect to X server message.

After ssh'ing and opening an existing tmux session from home, how do I later reattach the ability to open up GUI stuff on the desktop?

The ssh'ing from home seems to make the tmux session forget that it can spawn GUI stuff.

EDIT:

  • Bit confused. Are you using the -X flag now or not? You can only do X11 stuff through SSH if that's set. – Anko Jul 25 '14 at 21:09
  • Sorry for the confusion. I never use the -X flag, anywhere. I do not intend on doing X11 stuff through SSH. I only intend on using X11 on my desktop, where the tmux session actually lives. I'll update the original question. – chrisdembia Jul 26 '14 at 23:23
5

I had the same issue. I normally use tmux as part of a multi-monitor X11 desktop environment, and sometimes ssh in from a chromebook, which doesn't support X11 or set $DISPLAY. The answer by @chrisdembia works, but requires changing DISPLAY in each new window for the rest of the tmux session, which is a pain.

A permanent solution is to remove DISPLAY from the tmux update-environment variable in the tmux settings. You can see your current value with this command:

tmux show-options -g update-environment

To remove it, I added this line to my ~/.tmux.conf file, including everything but DISPLAY:

set-option -g update-environment "SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY"

This is further explained at Reset the shell DISPLAY variable in a tmux session over ssh, which explains why DISPLAY is there by default, for a different common use case.

| improve this answer | |
4

All I need to do is set the DISPLAY environment variable to :0.0. I think the issue was that I am using the fish shell, and I need to use the -x flag to set when doing this:

set -x DISPLAY :0.0
| improve this answer | |
  • 3
    Note that the correct value for DISPLAY might be different from :0.0. A quick way to find out is to create a new tmux window and echo $DISPLAY there. – j08lue May 11 '15 at 8:32
  • 1
    Just extending the comment from @j08lue; in my case echo $DISPLAY returned localhost:10.0 and running set DISPLAY localhost:0.0 did the trick. – IsaacS May 14 '16 at 0:56
  • 1
    Does anyone know a bash equivalent, or a cross-shell version? set -x just increases verbosity for me in bash. @IsaacS, did you have to set DISPLAY localhost:10.0 instead or did localhost:0.0 work for you? – icedwater Apr 26 '17 at 9:26
  • 4
    On bash, you should be able to use export DISPLAY=:0.0. – chrisdembia Jun 2 '17 at 0:48
  • 1
    I don't like this solution, since I have to do it for every new window for the rest of the session (which lasts weeks for me). And it happens even when I'm back on my main X11 system creating new windows. How can we get tmux to stop unsetting $DISPLAY? – nealmcb Oct 16 '18 at 17:56
0

tmux fight with matplotlib:

export MPLBACKEND='Agg'
| improve this answer | |
  • Welcome to the site, and thank you for your contribution. To make the answer useful to a wider range of audiences, would you mind editing your post to explain why this will serve to solve the OPs problem (possibly with links to external sources as reference)? – AdminBee Jul 15 at 8:18
  • @AdminBee i have tested this configuration on my tmux, my answer doesn't cover all of this kind of problems. it solved my problem. – sailfish009 Jul 15 at 9:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.