January 16, 2020

macOS and the X Window System with XQuartz

xeyes

macOS and the X Window System

If you want to use the X Window System on macOS, you need XQuartz.

Install XQuartz

brew cask install xquartz

After a Reboot you will get the $DISPLAY set correctly. If you want to set it without a reboot see Start XQuartz temprorary

Test with xeyes

/opt/X11/bin/xeyes

xeyes

SSH X11Forwarding

You can now use ssh -X or ssh -Y

Uninstall

brew cask uninstall xquartz

Start XQuartz temprorary

This is only necessary if you want to start XQuartz without a reboot.

launchctl load /Library/LaunchAgents/org.macosforge.xquartz.startx.plist
launchctl start org.macosforge.xquartz.startx

Set DISPLAY

find the socket

Note the time when you started xquartz

ls -l /private/tmp 
total 0
drwx------  3 harry  wheel  96 16 Jan 15:53 com.apple.launchd.Kxdk75I3PA
...

➜  ~ ls -l /private/tmp/com.apple.launchd.Kxdk75I3PA/org.macosforge.xquartz:0 
srw-rw-rw-  1 harry  wheel  0 16 Jan 15:53 /private/tmp/com.apple.launchd.Kxdk75I3PA/org.macosforge.xquartz:0

Set $DISPLAY

export DISPLAY=/private/tmp/com.apple.launchd.Kxdk75I3PA/org.macosforge.xquartz:0
echo $DISPLAY
/private/tmp/com.apple.launchd.Kxdk75I3PA/org.macosforge.xquartz:0

Test

/opt/X11/bin/xeyes 

All rights reserved - 2019

Powered by Hugo & Kiss.