When I first start my screen session my X-display works. I.e., I can start X-apps like xterm, etc.

However, when I reattach my previous screen session, from a different X, the X-display no longer works. E.g., if I start xterm, I'll get:

xterm: Xt error: Can't open display: localhost:10.0

However my X-display (of localhost:10.0) works just find if I quit/suspend the reattach screen session. I.e., it works outside of reattach screen session, but not inside.

How to make my X-display works inside of the reattach screen session as well?

  • Are you using SSH with X11 forwarding? – gogators Jan 19 '16 at 19:54
  • SSH, but not X11 forwarding in the question. – xpt Jan 20 '16 at 2:14

Before reattach screen session,

env | grep -E "SSH_|DISPLAY|XAUTHORITY" > ~/.scrrc

After reattach, within each screen session,

source ~/.scrrc

Define them as alias to ease typing each time.

| improve this answer | |
  • 1
    Better to do env | grep -E "SSH_|DISPLAY|XAUTHORITY" | sed -e "s/\=\(.*\)$/=\"\1\"/" > ~/.scrrc, because bash variable assignment cannot contain unescaped spaces. – Velda Aug 30 '17 at 8:44

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.