Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Use other terminal apps with Apple's X11' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use other terminal apps with Apple's X11
Authored by: n8gray on Aug 26, '04 02:33:04PM

Sorry, but this hint is a terrible idea. There are plenty of good ways to use iTerm, Terminal, or whatever terminal you want with X but this isn't one of them. Any time you find yourself replacing a system file with a script it's a pretty good hint that you're doing something wrong. To do it right:

  • Method 1: Write your own $HOME/.xinitrc file that launches iTerm. Use /etc/X11/xinit/xinitrc as an example. With this technique you will only be able to launch X11 apps from the iTerm session that you launch with X11, and only if it's not already running before you start X11.
  • Method 2: Make any one iTerm know about the server. In an iTerm window type
    export DISPLAY=:0
    and you should now be able to use X11 programs in that window, provided the X11 server is running.
  • Method 3: Make all iTerms know about the server. Create a file called $HOME/.MacOSX/environment.plist with these contents:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" 
    "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
            <key>DISPLAY</key>
            <string>:0</string>
    </dict>
    </plist>
    
    Log out and log in again. Now any iTerm, Terminal.app, glTerm, or whatever should be able to launch X11 programs whenever the X11 server is running. This method is the same as the above method, but it applies to all programs. A similar technique would be to put
    export DISPLAY=:0
    in your $HOME/.bash_profile file, but that can cause complications if you're connecting to your machine remotely and it only works if you use bash as your shell.


[ Reply to This | # ]
Use other terminal apps with Apple's X11
Authored by: szedula on Aug 26, '04 09:24:34PM
Using "csh" (I don't know about "bash") n8gray's "complication":
...but that can cause complications if you're connecting to your machine remotely and it only works if you use bash as your shell.

Can be solved using the following in ".login":
if ($?REMOTEHOST) then
   setenv DISPLAY ${REMOTEHOST}:0.0
else
   setenv DISPLAY :0.0
endif
when the remote system is a Mac.

[ Reply to This | # ]
Use other terminal apps with Apple's X11
Authored by: MaxMarino on Aug 27, '04 09:31:10AM
This is the bash version:
if [ -z "$DISPLAY" ]; then
    if [ -n "$REMOTEHOST" ]; then
        export DISPLAY=$REMOTEHOST:0.0
    else
        export DISPLAY=:0.0
    fi
fi
and indeed it is ok if you are only user on your Mac: I have this on my Powerbook. You may add/merge with an hint submitted by Christoph in May this year:
# try to figure out DISPLAY cleverly
DISPLAY=""
for x in 0 1 2 3 4 5 6 7 8 9
do
  if [ -O /tmp/.X$x-lock ]
      then
      DISPLAY=:$x.0
      break
  fi
done
if [ -z "$DISPLAY" ]
    then
    echo "$USER has no X11 DISPLAY open" 1>&2
    exit 1
fi
export DISPLAY
the files in /tmp increments with users starting their X11 on their sessions so it sets the DISPLAY correctly with multiple users and FUS.

[ Reply to This | # ]
Use other terminal apps with Apple's X11
Authored by: EddEdmondson on Aug 27, '04 03:05:48AM

Good idea but there's one flaw with what you're doing:

The DISPLAY variable is only 0 if you are the first user running X11.app. If you FUS to another user and start another X11.app the DISPLAY variable will be 1. To do things properly you probably need a clever Applescript to switch to X11.app and try to get the variable from there and pass it back.

If you're the sole user on your machine you'll be fine - but beware if you aren't!!



[ Reply to This | # ]
Solution?
Authored by: EddEdmondson on Aug 27, '04 03:09:03AM

A possible alternative to the problems with the DISPLAY variable taking on other values - arrange for your .xinitrc file to place the DISPLAY variable in a file like '.x11appdisplay' in your home directory, and parse its contents if the X11.app is found to be running on the start of a shell. I'll leave the details of this as an exercise for the reader based on other posted scripts!



[ Reply to This | # ]