Skip to content

Instantly share code, notes, and snippets.

@jclosure
Created August 6, 2017 00:20
Show Gist options
  • Save jclosure/72cefed87528917daac9f65a2029a5dc to your computer and use it in GitHub Desktop.
Save jclosure/72cefed87528917daac9f65a2029a5dc to your computer and use it in GitHub Desktop.
How to install Dia on OSX (and have it run)
brew cask install dia

After his it won't run because DISPLAY=:0 env var is not set

vim /Applications/Dia.app/Contents/Resources/bin/dia

Add the following content to line 40 (right before the oascript call)

#########################################################
# Ref: http://navkirats.blogspot.de/2014/10/dia-diagram-mac-osx-yosemite-fix-i-use.html
versionOSX=$(sw_vers -productVersion | awk -F '.' '{print $(NF-1)}')
[[ ${versionOSX} -ge 10 ]] && export DISPLAY=:0
#########################################################
@sriegler
Copy link

Just had the same issue, thanks for working it out. I have another solution suggestion, which extends it's script and Makefile usage, which I require.

There is no need to introduce further logic into the script, if you are on newer versions of macOS, just hardcode display :0 into the dia-bin parameters and fix the dia script not passing on additional command line parameters in one go. So you can use it properly on the command line as well, e.g. scripts, Makefiles:

Change the last line, where it executes the actual dia binary, from:

File: /Applications/Dia.app/Contents/Resources/bin/dia

exec "$CWD/dia-bin" --integrated

to:

exec "$CWD/dia-bin" --integrated --display=:0 "$@"

and include /Applications/Dia.app/Contents/Resources/bin into your PATH/.profle and you are all set. Now you can start Dia.app as well call dia -e [...] from the command line if PATH is set.

If you want to prevent XQuartz from opening the additional terminal window, just put export DISPLAY=:0 like described above before the osascript call on line 40.

@dokester
Copy link

Thanks. It is working again on my Macbook M1 under Sonoma.

@lgsevilla
Copy link

Thanks, still works on MacBook Pro M3 Pro, Sequoia 15.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment