Can't open display after reattach screen session

1

1

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?

xpt

Posted 2016-01-19T19:51:27.697

Reputation: 5 548

Are you using SSH with X11 forwarding? – gogators – 2016-01-19T19:54:45.493

SSH, but not X11 forwarding in the question. – xpt – 2016-01-20T02:14:40.167

Answers

0

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.

xpt

Posted 2016-01-19T19:51:27.697

Reputation: 5 548

1Better to do env | grep -E "SSH_|DISPLAY|XAUTHORITY" | sed -e "s/\=\(.*\)$/=\"\1\"/" > ~/.scrrc, because bash variable assignment cannot contain unescaped spaces. – Velda – 2017-08-30T08:44:53.207