TweetFollow Us on Twitter

X11 Tweaks

Volume Number: 19 (2003)
Issue Number: 5
Column Tag: Section 7

X11 Tweaks

Making X11 Play Nicely on the Mac

by Rich Morin

Tweaking X11 isn't for everyone. You'll find yourself editing configuration files, rummaging through voluminous FAQs and man pages, and whining piteously to folks on assorted mailing lists. Even if you're a dedicated hacker, you may begin to wonder whether this is the way you want to spend your time.

More to the point, you may not need to tweak X11. If, like many users, you only run commands by means of the X11 "Applications" menu, adding a few commands to the list may be all you ever need to do. The syntax may be arcane, but the commands are short and the effects of a mistake are limited to the command involved.

Even if you want to run apps from the command line, there are ways to avoid hacking. If you're only running X11 apps locally (i.e., on your desktop machine), you can start them up by means of Apple's open-x11 command. This is an (undocumented) X11 analog to open(1), which starts up OSX apps. If you have X11 running, you can start up a local copy of xclock(1) by typing the following at any shell prompt:

open-x11 xclock

In short, most X11 tweaking is entirely optional. I would suggest, however, that you put /usr/bin/X11R6 into your PATH variable. This will allow you read the X11 man pages and run X11 apps without the need for open-x11.

If you're a csh(1) user, add the following to your ~/.login file:

setenv PATH "${PATH}:/usr/X11R6/bin"

If you're a bash(1) user, add the following to your $HOME/.bash_login file:


By some cute trickery, described in manpath(1), the same information is to set up manual page lookups. Basically, if PATH contains a bin directory, the corresponding man directory is searched when man(1) is run.

So much for X11 tweaking, folks. That's it, all done, move along, nothing more to see here...

Still Here?

If you have more stringent requirements (or aren't entranced with Apple's "stock" X11 configuration), you may be interested in hearing about some useful "tweaks" I've run across. Even if you don't share my situation or tastes, it's useful to know how to customize X11.

Until someone provides a GUI-based configuration tool, modifying X11's behavior will require users to edit text files, specifically, start-up scripts. The "system-wide" X11 start-up script is named /etc/X11/xinit/xinitrc; personal ones go in ~/.xinitrc. Let's walk through the system version, so you'll know which lines do what.

If xinitrc were a normal, executable script, the first line would tell the system which interpreter (i.e., /bin/sh) to use on it. In fact, things are a bit weirder than that. /bin/sh is nominally the path to sh(1), the Bourne shell; like many other vendors, however, Apple has chosen to substitute bash(1), the GNU Project's Bourne-Again SHell, running in "POSIX" mode. Normally, this substitution is invisible, but it's nice to know what's what.

In this particular case, however, the line is simply treated as a comment. Apple's X11 implementation (like many others) always uses /bin/sh to interpret its start-up files, so changing the requested interpreter wouldn't make any difference at all!

The first two characters (#!) of the script's initial line, incidentally, are commonly pronounced "pound bang" or perhaps "shebang". The second line is a comment which contains version information from rcs(1), the "revision control system" that was used in maintaining this file.

# $Id: xinitrc,v 1.2 2003/02/27 19:03:30 jharper Exp $

The next four lines define some shell variables, used to specify file locations. $HOME is an "environment variable" which is set at login time to the user's home directory. /etc is a traditional location for Unix control files; /etc/X11/xinit, predictably, is an X11-specific subdirectory for initialization files.


Next, the script checks for the existence of each file, executing a specific command if the file is present. xmodmap(1) is a utility for modifying keymaps and pointer button mappings; xrdb(1) is a resource database utility.

# merge in defaults and keymaps
if [ -f $sysresources ]; then
    xrdb -merge $sysresources
if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
if [ -f $userresources ]; then
    xrdb -merge $userresources
if [ -f $usermodmap ]; then
    xmodmap $usermodmap

With all of the settings loaded, the server is in a position to start up some programs. First, it starts up an instance of xterm(1), a terminal emulator. The ampersand at the end of the line forces the program to run in the background (that is, detached from the shell process that is interpreting this script).

Finally, the script starts quartz-wm(1), the Aqua Window Manager for the X Window System on OS X. The exec command tells the current shell session to replace itself by the window manager (as opposed to waiting around for the window manager to finish). Consequently, any commands placed after the exec line will be ignored.

# start some nice programs
xterm &
# start the window manager
exec quartz-wm


As discussed in an earlier column ("X11: A C of Window Systems"), X11's goal is to provide "mechanism, not policy". This makes it highly customizable, but it also means that there are a great number of possible configurations, depending on each user's preferences and the methods chosen to achieve them. In short, don't expect Macintosh-style simplicity.

Although the system-wide control files are important to understand, I'd recommend strongly against editing them. Apple is quite likely to change one or more of these files in an update, so your changes might quietly disappear. Also, if there are any other users on your system, it might be considered bad form to give them a "non-standard" configuration.

Instead, create personal control files (~/.Xmodmap, ~/.Xresources, and/or ~/.xinitrc). If you only want to add or override some default settings, the first two of these may be sufficient. The start-up script will use any settings you put into your personal files, after the system-wide settings have been loaded.

To change X11's start-up behavior, copy /etc/X11/xinit/xinitrc to ~/.xinitrc (be sure to include the initial period!), then edit the copy. When the X11 server detects ~/.xinitrc, it will use the personal script instead of the system-wide script, so be sure to include any lines (from the original script) that you want to have run!

Rich's X11 Tweaks

Here is a personal set of tweaks, based on my own situation and preferences. They won't be the best choice for every situation, but they work well for me and show, in any case, how this sort of thing can be done.

My goal is to have a consistently Mac-like environment, allowing me to edit files and run commands on both my desktop Mac (cerberus) and a remote FreeBSD box (cfcl). I should be able to run X11 apps on either the desktop or remote machine, by means of the command line or the X11 server's "Applications" menu.

Most users run X11 apps by means of the mouse, so let's look at setting up some entries in the Applications menu. Because X11 is a network-friendly window system, we can put in either local or remotely-executed commands:

xclock -title cerberus
ssh -X cfcl xclock -title cfcl
xterm -bg 'pink' -geometry =80x60

The first two commands, above, start up instances of xclock(1) on cerberus and cfcl, respectively. The "-title" option, described in X(1), is used to indicate which machine the app is running on. The last command sets up an 80 column by 60 line xterm(1), using a garish pink background color (to distinguish it from Terminal windows).

The $PATH modifications described at the beginning of the article let me look up X11 commands and run them from the command line. Speaking of command lines, however, let's set up Terminal (yay!) as a substitute for xterm (feh!).

The default xinitrc file tells the X11 server to start up an xterm. Because this xterm doesn't have the desired characteristics (i.e., preset size and background color), I might as well get rid of it. So, I create a personal start-up file and then comment out the offending line:

# xterm &

I could, if desired, start up some number of xterm windows from this file, specifying their sizes, colors, initial positions, and many other attributes. I'm not going to do this, however, because I seldom want to run xterm at all. The Terminal works just fine for me and xterm's appearance and behavior aren't even faintly Mac-like, so why use it?

Unfortunately, this leaves me with a small problem. X11 applications use an environment variable (DISPLAY) to tell them where they should present their output (and get input such as keyboard and mouse actions). Because the xterm above was being started up by X11, this variable was being set for it automagically. How can I get DISPLAY to be set for Terminal?

If I'm willing to keep a copy of X11 running all the time, there's a really simple solution: run Terminal from the X11 start-up script! As a "child" of X11, the Terminal process will inherit DISPLAY in exactly the same way that xterm (or any other app) would. Terminal goes into the background on its own, incidentally, so we don't need an ampersand:

open /Applications/Utilities/

Obviously, X11 depends heavily on the DISPLAY variable; if the variable gets trashed, bad things will start to happen. Worse, the cause of the problem may not be obvious. So, I wrote a simple "sanity check", which goes into the ~/.login file on the remote machine:

if ($?DISPLAY) xdpyinfo > /dev/null

xdpyinfo(1) is a utility for displaying information about an X11 server. If DISPLAY is set at login time, this program will be run. Although the normal output is discarded, I'll find out about any DISPLAY problems from the program's error messages. (In proper Unix fashion, these are output to standard error, which is not discarded.)

X11 Forwarding

ssh(1) is the modern replacement for telnet(1). It is secure, reliable, and has some very nifty features (one of which we're about to use :-). When I log in to a remote machine, I want any X11 commands I run to display their windows on my desktop machine. This means I need a secure path for the X11 protocol (and I don't want to worry much about how it's done :-).

X11 forwarding is the "silver bullet" that solves this problem. The ssh command (on the desktop machine) exchanges some information with sshd(8), the daemon process on the remote machine. When they're done, there's a secure communication path for my session!

There are two ways to ask for X11 forwarding. Adding the "-X" option to the ssh command line is the simplest, but it only affects a single session. If you want all of your ssh sessions to do forwarding, you can add the following line to the end of /etc/ssh_config, but remember that an update may overwrite the file:

ForwardX11 yes

I decided, instead, to create an alias (in ~/.cshrc) that sets up X11-forwarded ssh sessions on cfcl:

alias cfcl 'ssh -X cfcl'

In any case, I can now start up X11 (with no annoying xterm window showing up) and type commands into convenient, Mac-friendly Terminal windows. Using the "-title" option, described in X(1), I can even identify the machine an app is running on:

rdm@cerberus [~] 1: xclock -title cerberus &
rdm@cerberus [~] 2: cfcl
rdm@cfcl [~] 1: xclock -title cfcl &

The result, as shown in the figure, is a pair of clocks. One is running on cerberus (my Mac OS X desktop machine); the other is running on cfcl (the FreeBSD box downstairs). Both show up on my desktop, however, proving that I got everything right (except keeping the system clocks synchronized :-).

Another Approach

One objection to this approach is that it requires the X11 server to run all the time. I don't use X11 all that much, so this seems a bit heavy-handed. On the other hand, it is both simpler and safer than the method I'm about to describe. In short, proceed further at your own risk...

There are many ways to set environment variables. If you add the following line to your ~/.login file, it will get run for each new Terminal window:

if (! $?DISPLAY) setenv DISPLAY ':0'

This code is a bit subtle, so an explanation may be in order. If DISPLAY is already set (as it would be if we were coming in from an xterm), we don't want to destroy the existing setting. Otherwise, however, we're free to set up the variable.

Note: Some programs (e.g., GNU Emacs) take the existence of DISPLAY as a guarantee that an X11 server is available. If Emacs tries to talk to a nonexistent server, predictably bad things will happen. Of course, you can unset the variable before you start up Emacs, but that may seem a bit kludgy:

% (unsetenv DISPLAY; emacs foo)

Don't tell any real X11 enthusiasts that you're setting DISPLAY, by the way, unless you're ready for an extended lecture on how things are supposed to be done. For that matter, this is a klunky and somewhat fragile hack, but it works for me (:-).


I'd like to thank the patient and helpful folks on X11-users (the X11 for Mac OS X discussion list) for helping me find the information for this article. If you're planning to use X11 on OSX, be sure to join this list (

I'd also recommend that you familiarize yourself with Apple's "X11 Public Beta FAQ", the "X11: Frequently Asked Questions" thread on The MacOSXhints Forums, and the "X11 for OS X Unofficial FAQ":

Even if you're not planning to do X11 development, you should grab a copy of Apple's "X11 for Mac OS X Public Beta SDK". Most X11 packages are distributed in source form; if you want to build them, you'll need the SDK!

Speaking of X11 (and other) packages for OSX, Fink is a popular and frequently recommended source for pre-compiled binaries, etc:

Rich Morin has been using computers since 1970, Unix since 1983, and Mac-based Unix since 1986 (when he helped Apple create A/UX 1.0). When he isn't writing this column, Rich runs Prime Time Freeware (, a publisher of books and CD-ROMs for the Free and Open Source software community. Feel free to write to Rich at


Community Search:
MacTech Search:

Software Updates via MacUpdate

Amazon Chime 4.6.5852 - Amazon-based com...
Amazon Chime is a communications service that transforms online meetings with a secure, easy-to-use application that you can trust. Amazon Chime works seamlessly across your devices so that you can... Read more
VOX 2.8.30 - Music player that supports...
VOX just sounds better! The beauty is in its simplicity, yet behind the minimal exterior lies a powerful music player with a ton of features and support for all audio formats you should ever need.... Read more
iFFmpeg 6.4.3 - Convert multimedia files...
iFFmpeg is a comprehensive media tool to convert movie, audio and media files between formats. The FFmpeg command line instructions can be very hard to master/understand, so iFFmpeg does all the hard... Read more
Alfred 3.4.1 - Quick launcher for apps a...
Alfred is an award-winning productivity application for OS X. Alfred saves you time when you search for files online or on your Mac. Be more productive with hotkeys, keywords, and file actions at... Read more
SyncTwoFolders 2.2.4 - Syncs two user-sp...
SyncTwoFolders simply synchronizes two folders. It supports synchronization across mounted network drives and it is a possibility to run a simulation showing in a log what will be done. Please visit... Read more
Maintenance 2.2.7 - System maintenance u...
Maintenance is a system maintenance and cleaning utility. It allows you to run miscellaneous tasks of system maintenance: Check the status of the hard disk Repair permissions Run periodic scripts... Read more
Hopper Disassembler 4.2.13- - Binary dis...
Hopper Disassembler is a binary disassembler, decompiler, and debugger for 32- and 64-bit executables. It will let you disassemble any binary you want, and provide you all the information about its... Read more
NeoOffice 2017 - Mac-tailored, OpenOffic...
NeoOffice is a complete office suite for OS X. With NeoOffice, users can view, edit, and save OpenOffice documents, PDF files, and most Microsoft Word, Excel, and PowerPoint documents. NeoOffice 3.x... Read more
Firefox 55.0.2 - Fast, safe Web browser.
Firefox offers a fast, safe Web browsing experience. Browse quickly, securely, and effortlessly. With its industry-leading features, Firefox is the choice of Web development professionals and casual... Read more
Alfred 3.4.1 - Quick launcher for apps a...
Alfred is an award-winning productivity application for OS X. Alfred saves you time when you search for files online or on your Mac. Be more productive with hotkeys, keywords, and file actions at... Read more

War Wings beginner's guide - how to...
War Wings is the newest project from well-established game maker Miniclip. It's a World War II aerial dogfighting game with loads of different airplane models to unlock and battle. The game offers plenty of single player and multiplayer action. We... | Read more »
How to win every 2v2 battle in Clash Roy...
2v2 is coming back to Clash Royale in a big way. Although it's only been available for temporary periods of time, 2v2 has seen a hugely positive fan response, with players clamoring for more team-based gameplay. Soon we'll get yet another taste of... | Read more »
Roll to Win with Game of Dice’s new upda...
Joycity’s hit Game of Dice gets a big new update this week, introducing new maps, mechanics, and even costumes. The update sets players loose on an exciting new map, The Cursed Tower, that allows folks to use special Runes mid-match. If you feel... | Read more »
Bottom of the 9th (Games)
Bottom of the 9th 1.0.1 Device: iOS iPhone Category: Games Price: $4.99, Version: 1.0.1 (iTunes) Description: Play the most exciting moment of baseball in this fast-paced dice and card game! | Read more »
The best apps for viewing the solar ecli...
If you somehow missed the news, many parts of the United States will be witness to a total solar eclipse on August 21 for the first time in over 90 years. It'll be possible to see the eclipse in at least some capacity throughout the continental U... | Read more »
The 5 best mobile survival games
Games like ARK: Survival Evolved and Conan Exiles have taken the world of gaming by storm. The market is now flooded with hardcore survival games that send players off into the game's world with nothing but maybe the clothes on their back. Never... | Read more »
Portal Walk (Games)
Portal Walk 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: Portal Walk is adventure and relaxing platform game about Eugene. Eugene stuck between worlds and trying to find way back home.... | Read more »
Technobabylon (Games)
Technobabylon 1.0 Device: iOS Universal Category: Games Price: $4.99, Version: 1.0 (iTunes) Description: City of Newton, 2087. Genetic engineering is the norm, the addictive Trance has replaced almost any need for human interaction,... | Read more »
5 reasons why 2v2 is the best mode in Cl...
Supercell has been teasing fans with 2v2 windows that allow players to team up for limited periods of time. The Summer of 2v2 was just this past July, but players are already clamoring for more of that sweet, sweet team-based action. The fans have... | Read more »
The best deals on the App Store this wee...
It seems like the week's only just started, and yet here we are with a huge pile of discounted games to sort through. There are some real doozies on sale this week. We're talking some truly stellar titles. Let's take a look at four of the best... | Read more »

Price Scanner via

13-inch 2.3GHz MacBook Pros on sale for $100...
Amazon has the new 2017 13″ 2.3GHz MacBook Pros on sale today for $100 off MSRP, each including free shipping: – 13″ 2.3GHz/128GB Space Gray MacBook Pro (MPXQ2LL/A): $1199.99 $100 off MSRP – 13″ 2.... Read more
New iOS 11 Productivity Features Welcome But...
The iOS community is in late summer holding mode awaiting the September arrival of the iPhone 8 and iOS 11. iOS 11 public betas have been available for months — number six was released this week —... Read more
Samsung Electronics Launches New Portable SSD...
Samsung Electronics America, Inc. has announced the launch of Samsung Portable SSD T5 – its newest portable solid state drive (PSSD) that raises the bar for the performance of external memory... Read more
TrendForce Reports YoY Gain of 3.6% for 2Q17...
Market research firm TrendForce reports that the global notebook shipments for this second quarter registered a sequential quarterly increase of 5.7% and a year-on-year increase of 3.6%, totaling 39.... Read more
Sale! 10-inch iPad Pros for $50 off MSRP, no...
B&H Photo has 10.5″ iPad Pros in stock today and on sale for $50 off MSRP. Each iPad includes free shipping, and B&H charges sales tax in NY & NJ only: – 10.5″ 64GB iPad Pro: $599, save $... Read more
Sale! 2017 13-inch Silver 2.3GHz MacBook Pro...
Amazon has new 2017 13″ 2.3GHz/128GB Silver MacBook Pro on sale today for $100 off MSRP including free shipping. Their price is the lowest available for this model from any reseller: – 13″ 2.3GHz/... Read more
WaterField Unveils Collaboratively-Designed,...
In collaboration with customers and seasoned travelers, San Francisco maker WaterField Designs set out to create the preeminent carry-on system to improve the experience of frequent fliers. The... Read more
Miya Notes Mac-Client for Google Keep (Launch...
MacPlus Software has announced te launch of Miya Notes for Google Keep 1.0, a powerful Mac-client for Google Keep. Millions of people use Google Keep on their phones and online, but a convenient Mac... Read more
Apple refurbished iMacs available starting at...
Apple has previous-generation Certified Refurbished 2015 21″ & 27″ iMacs available starting at $849. Apple’s one-year warranty is standard, and shipping is free. The following models are... Read more
2017 13-inch MacBook Airs on sale for $100 of...
B&H Photo new 2017 13″ MacBook Airs on sale today for $100 off MSRP, starting at $899: – 13″ 1.8GHz/128GB MacBook Air (MQD32LL/A): $899, $100 off MSRP – 13″ 1.8GHz/256GB MacBook Air (MQD42LL/A... Read more

Jobs Board

Business Development Manager - *Apple* Medi...
Job Summary Apple Music is a single, intuitive app that...- all in one place. You can stream any Apple Music song, playlist or album, and download it Read more
Development Operations and Site Reliability E...
Development Operations and Site Reliability Engineer, Apple Payment Gateway Job Number: 57572631 Santa Clara Valley, California, United States Posted: Jul. 27, 2017 Read more
Frameworks Engineering Manager, *Apple* Wat...
Frameworks Engineering Manager, Apple Watch Job Number: 41632321 Santa Clara Valley, California, United States Posted: Jun. 15, 2017 Weekly Hours: 40.00 Job Summary Read more
Program Manager, *Apple* Pay Business Opera...
…Manager to deliver and sustain a seamless user and support experience for Apple Pay Cash, the upcoming person-to-person payments feature in iMessage. On the Business Read more
Sr. Software Engineer, Core Services, *Apple...
…You will be part of the server team that powers various features within the Apple client applications - iTunes, App Store, iBooks, Podcast, Apple Music etc. You Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.