Adam Lazur on Mon, 8 Sep 2003 17:52:06 -0400


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PLUG] Re: Propagating DISPLAY into screen sessions


Walt Mankowski (waltman@pobox.com) said:
>   C-c
>   % echo $DISPLAY
>   localhost:11.0
>   % C-a d
>   % echo $DISPLAY
>   localhost:13.0
>   % screen -x
>   % DISPLAY=localhost:13.0
>   % emacs foo.pl
> 
> While this (eventually) works, I'm getting annoyed that I have to
> manually reset DISPLAY all the time.  Is there any easy way to
> reattach to a screen session and get it to automatically propagate
> DISPLAY to all the sessions?

This is an often asked for feature, along with changing the SSH_AGENT
environment variable. There isn't a "good" builtin way to fix it, but
you can put a baindaid on the problem a couple of ways.

You can change the value of the DISPLAY variable in the parent process
(screen) by doing a C-a : setenv DISPLAY localhost:13.0

This will set the environment variable for new shells only, so you'll
have to C-a c once to see the new DISPLAY.

To automagically do this on re-attach, you could write a wrapper to your
re-attach which first does a "screen -X setenv DISPLAY $DISPLAY" and
then does the screen -x

This is complicated by a bug in some versions of screen where setenv
will only set new variables, but not overwrite old ones. In this case,
an unsetenv before the setenv can workaround it, or you could upgrade
screen to the latest version (3.9.15... soon to be 4.0.0).

Good luck.

-- 
Adam Lazur, Cluster Monkey
_________________________________________________________________________
Philadelphia Linux Users Group        --       http://www.phillylinux.org
Announcements - http://lists.netisland.net/mailman/listinfo/plug-announce
General Discussion  --   http://lists.netisland.net/mailman/listinfo/plug