Apple's X11.app and xterm copy/paste

| | Comments (3)

Okay, after some amount of beating and flogging, I have got Tiger and X11.app and xterm all playing nicely.

(Updated for fvwm note)

Okay, after some amount of beating and flogging, I have got Tiger and X11.app and xterm all playing nicely.All I want is this: xterm to behave like xterm. Apple to behave, like, well, an apple. And, while in my xterm, apple-V to act as a way to "paste".

For those not listening to my rants, XDarwin disabled the ability to use the meta key (er, the Apple key), somewhere between now and back when I last installed XFree86 via fink (during the Panther days). I've grown quite accustomed to Meta-V (er, Apple-V) acting as a "paste" key in xterm. I found this nasty suprise out when I bought my powerbook, and I had zero intentions of going back to using a mouse to paste. On a mac, apple-v is easy to reach, and feels natural!

After giving up on XDarwin (built from source), I revisited apple's X11. Going for Apple's implementation is that xquartz is supposed to be bad-ass fast, _and_ they fixed the z-order problem with "X" windows and "mac" windows interleaving.

X11.app does allow in preferences to pass the meta key unmolested. Yay!

I got "paste" working, kinda. With my old preferences file, copy/paste xterm to xterm was working. Apple apps to xterms, also worked. What was failing, was copying from an xterm and pasting into, say, Safari. No matter what, Safari kept pasting the last Apple only copy. The only work around, is Apple-C (if I allow X11 to take over "meta", and lose my Apple-V), or move the mouse to the menu bar and manually select "copy".

Being a ranter myself, I appreciate jwz's postings. In particular, he posted about some of this headache in particular with relation to emacs. Not entirely applicable, but.. it gave me the hints I needed.

macosxhints had another hint that helped. This one mentioned the tool "xclipboard". This showed promise - what I copied with the Mac was showing up in this clipboard, but not in xterm.

The crux of the problem is, there are multiple ways to copy/paste in "X". Apple chose only to monitor and sync "CLIPBOARD".

Finally, after enough other hints, the thought came to me - remap the xterm functions. Get them to prefer the "CLIPBOARD" over other methods of passing info! I have no idea how badly I hurt other apps, but I only use X for xterm (no, really!).

So, you want to do this, too?

Step 1

X11.app : go to Preferences ; disable "Enable keyboard shortcuts under X11"

Step 2

Update your .Xresources file . Create one if you don't have one.

My .Xresources file now looks like:


xterm*cursorColor: green
xterm*pointerColor: blue
xterm*foreground: white
xterm*background: black
rxvt*foreground: white
rxvt*background: black
rxvt*font: fixed
xterm*scrollBar: true
xterm*saveLines: 5000
xterm*color4: blue
xterm*trimSelection: true
xterm*printerCommand: cat >> /Users/jfesler/xterm-print-output

XTerm*VT100.Translations: #override \
<KeyPress> Prior: scroll-back(1,page) \n\
<KeyPress> Next: scroll-forw(1,page) \n\
Meta <KeyPress> W: quit() \n\
Meta <KeyPress> V: insert-selection(CLIPBOARD,PRIMARY,CUT_BUFFER0) \n\
<BtnUp>: select-end(CLIPBOARD,PRIMARY,CUT_BUFFER0) \n\



This changes mey keys to make Apple-V paste preferably from the CLIPBOARD; and that selecting text, will update all 3 copy buffers. Also note that Apple-W for me kills an xterm (without a warning).

Step 3

Update your .xinitrc to load your .Xdefaults file. Create one, if you don't already have one.

My .xinitrc looks like this:

#! /bin/sh

# fink
test -r /sw/bin/init.sh && . /sw/bin/init.sh

# Load the .Xresources file
xrdb -l .Xresources

# Sync the Apple clipboard with the X11 CLIPBOARD
quartz-wm --only-proxy &

# I like these.
xterm &

# My prefered rootless window manager.
fvwm2

# In case fvwm2 fails to start.. you can never have too many of these.
xterm


Step 4

Restart your X11.app . Test it out. Copy text from a "mac" app; try pasting it in an xterm. Copy text from an xterm, paste back into a mac app using apple-v.


fvwm

Added August 4, 2005

A friend hinted that he'd appreciated having Apple-N launch a new xterm. .Xresources won't do this. However, I did get it working under $HOME/.fvwm/.fvwm2rc ..

Key N A 2 Exec exec xterm

So, now, we have selecting text automatically copying; Apple-V pasting; and Apple-N spawning new xterms. Cool!

Categories

3 Comments

leon said:

Good it work's for me.
Tank's a lot :)

electronicpeter said:

28.4.2007
This works for me too! I use fvwm2 with X11 under mac os and am happy for these hints.
Thanx a lot.

fusionfan said:

Unfortunately still not working for me! Even after making the mods. My problem is that copying between X windows works fine, copying from X to aqua still works fine, but copying from aqua to X never worked :(

Leave a comment


About this Entry

This page contains a single entry by Jason Fesler published on August 3, 2005 8:58 PM.

Star Wars (1983) Arcade Game was the previous entry in this blog.

Dlink and long DHCP names is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.0