Zum Hauptinhalt springen
  1. Braindump/

CrossOver in einem Shell-Script unter macOS nutzen

1 min
Marcel Ryser
Autor
Marcel Ryser
Softwarearchitekt und Tech-Enthusiast aus Bern

Manchmal will ich Aufgaben mit Bash-Scripts automatisieren – auch wenn dazu eine Windows-Anwendung ausgeführt werden muss, besonders wenn es sie nur für Windows gibt. Wenn du CrossOver hast und nicht zusätzlich eine wine-Installation (über Homebrew oder MacPorts) einrichten willst, könnte das hier auch für dich funktionieren. Bei mir klappt es mit einer CrossOver-Installation.

Hier die Schritte, die ich für ein Shell-Script gebraucht habe.

# Start CrossOver, otherwise the X11 server from CrossOver wasn't found when executing wine (from CrossOver)
open -a CrossOver

# Now quite a few variables should be set, so wine should find everything it needs.
export 'DYLD_FALLBACK_LIBRARY_PATH'='/Applications/CrossOver.app/Contents/SharedSupport/X11/lib:/Users//lib:/lib:/usr/lib:/usr/X11/lib'
export 'FONTCONFIG_ROOT'='/Applications/CrossOver.app/Contents/SharedSupport/X11'
export 'FONTCONFIG_PATH'='/Applications/CrossOver.app/Contents/SharedSupport/X11/etc/fonts'
export 'FONT_ENCODINGS_DIRECTORY'='/Applications/CrossOver.app/Contents/SharedSupport/X11/lib/X11/fonts/encodings/encodings.dir'
export 'VERSIONER_PERL_PREFER_32_BIT'='yes'
export 'CX_BOTTLE_PATH'='/Users//Library/Application Support/CrossOver/Bottles'
export 'CX_ROOT'='/Applications/CrossOver.app/Contents/SharedSupport/CrossOver'
export 'CX_BOTTLE'='winxp' # <-- You can set the bottle to execute the .exe in, this is helpful when the .exe has some dependencies!

# Determine the DISPLAY variable since this can change sometimes
export 'DISPLAY'=':'$(defaults read com.codeweavers.CrossOver Display)

# Now we extend the PATH variable and put the bin from CrossOver at the first possible location, to not collide with an 
# additional wine installation you might have
export 'PATH'='/Applications/CrossOver.app/Contents/SharedSupport/CrossOver/bin:'$PATH

# Now we can start the application however we ant
wine <path to .exe> <parameters>

Ersetze einfach die Platzhalter <path to .exe> und <parameters> durch deine Anwendung – fertig.