Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Hatred for ssh sessions spawning X11.app



In my last mail, I mentioned that an ssh connection using X forwarding will
spawn X11.app. I hate this. So, here's my workaround that some others may
like to use. It's pretty beta, and I'm sure it's got some flaws.. I wrote it
in about 10 minutes last night in anger.

Add the following to your .bashrc or similar. (this was written for zsh, so
I'm not sure if the function will work, you may need to remove the "()"
after "startx". Also, ">!" may not be valid in bash..).

--------------------------------8<-------------------------------
# Deal with $DISPLAY
if [ -e "$DISPLAY" ];then
   dpyfile=~/.Xdisplayvar
   update=yes
   if [ -f $dpyfile ];then
      if [ "$DISPLAY" = "$(cat $dpyfile)" ];then
         update=no
      fi
   fi

   if [ "yes" = "$update" ];then
      echo "$DISPLAY" >! $dpyfile
   fi
   unset update dpyfile

   export DISPLAY=
fi

startx() {
   export DISPLAY=$(cat ~/.Xdisplayvar)
   xhost
}
--------------------------------8<-------------------------------

Basically, if you want to start using X via a shell, just type 'startx'.

This is broken enough that it'll have effect in the shell started in an
xterm - you'd have to 'startx' there too. I may get around to enhancing it
to not blat out $DISPLAY if X11 is running.

Mike.
-- 
Mike Beattie  <email@hidden>     UNIX Systems Engineer, ITS
Ph: +64 3 479 8597       Fax: +64 3 479 5080       Cell: +64 21 626 624
* Opinions expressed are my own, not those of the University of Otago *

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
X11-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/x11-users/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.