Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I've got a problem with using Dia from the command line on OSX 10.7.4. I downloaded and installed the OS X dmg from http://dia-installer.de/download/macosx.html I've been using it to create graphics for a paper and absolutely love it.

I'm using a makefile to call pdflatex, bibtex, and R so that that it will build everything from scratch if need be, but can't get Dia's command line to work.

I want to use the command line with -e and -t to export the graphics to a specific directory so that pdflatex can put them in the pdf. (http://dia-installer.de/doc/en/re01.html)

The problem that I'm running into is that anytime I call it from the terminal, it brings up the GUI. Even if I give move to /Applications/Dia.app/Content/Resources/bin/ and use the command "./dia -v". It gives me a bunch of errors about "Input method" and then shows the GUI.

I looked on the Dia FAQ and it has a lot of information for the Windows command line, but nothing for OS X.

I'm hoping that someone here has run into this before and knows how to get it to work.

share|improve this question
    
Looks like dia is an X windows program so I would try live.gnome.org/Dia/… –  Mark Jul 18 '12 at 17:52
add comment

3 Answers 3

up vote 1 down vote accepted

On the Mac, dia (specifically /Applications/Dia.app/Content/Resources/bin/dia) is just a shell script wrapper to the compiled dia-bin binary. It sets a number of environmental variables, and then finishes by executing Dia as a GUI:

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

You can make a copy (e.g. cp -p dia dia-cmd) and edit that last line in dia-cmd to become:

"$CWD/dia-bin" $@

and then you can use it as dia-cmd within the terminal.

Note: I found that for my locale (en_US.UTF-8), at least, running dia-cmd in the terminal was way too chatty about trying to determine the correct locale, spewing ignorable warnings:

Warning: AppleCollationOrder setting not found, using AppleLocale.
Setting Language: en.UTF8

(process:33043): Gdk-WARNING **: locale not supported by C library

(process:33043): Gtk-WARNING **: Locale not supported by C library.
    Using the fallback 'C' locale.

You can eliminate that by also commenting-out those lines in dia-cmd, and manually forcing the correct locale:

## LANGSTR=`defaults read .GlobalPreferences AppleCollationOrder 2>/dev/null`
## if [ "x$LANGSTR" == "x" ]
## then
##    echo "Warning: AppleCollationOrder setting not found, using AppleLocale." 1>&2
##    LANGSTR=`defaults read .GlobalPreferences AppleLocale 2>/dev/null | \
##            sed 's/_.*//'`
## fi

# NOTE: Have to add ".UTF-8" to the LANG since omitting causes Dia
#       to crash on startup in locale_from_utf8().
## export LANG="$LANGSTR.UTF8"
 export LANG="en_US.UTF-8"
## echo "Setting Language: $LANG" 1>&2

Voila:

MYMACHINE:~ lars$ /Applications/Dia.app/Contents/Resources/bin/dia-cmd -v
Dia version 0.97.2, compiled 18:51:13 Mar 17 2012
share|improve this answer
    
You are right on the money. Much appreciated. –  Bit Monkey Jul 26 '12 at 3:02
add comment

Based on the accepted answer, I created dia-cli and a shortcut, dia:

cd /Applications/Dia.app/Contents/Resources/bin
cp -p dia dia-cli

cd /usr/local/bin
touch dia
sudo +x dia

Contents of /Applications/Dia.app/Contents/Resources/bin/dia-cli:

...
"$CWD/dia-bin" $@

Contents of /usr/local/bin/dia:

PATH=$PATH:/Applications/Dia.app/Contents/Resources/bin
/Applications/Dia.app/Contents/Resources/bin/dia-cli "$@"
share|improve this answer
add comment

If you're able to operate the commandline, you might also be interested in compiling Dia yourself on Mac OS X using MacPorts. Such an installation will not include the wrapper script that caused the above mentioned problems. Just install MacPorts from http://www.macports.org/ and run sudo port install dia

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.