Skip to content

Instantly share code, notes, and snippets.

@taldehyde
Last active August 29, 2015 14:06
Show Gist options
  • Save taldehyde/75e60495d6f57286b056 to your computer and use it in GitHub Desktop.
Save taldehyde/75e60495d6f57286b056 to your computer and use it in GitHub Desktop.
on open openedFiles
set validExtensions to {"exe"}
set winExe to item 1 of openedFiles
if name extension of (info for winExe) is not in validExtensions then
display dialog "invalid file"
return
else
set toRun to the POSIX path of winExe as text
end if
--edit winePrefix if you are not using the default prefix
set winePrefix to "$HOME/.wine"
--edit wineLocation if your wine install is not the default location
set wineLocation to "/usr/local/bin"
--edit dyldFallbackLibraryPath to your X11 lib folder, this one is set for XQuartz on 10.6+
set dyldFallbackLibraryPath to "/opt/X11/lib"
-------------------------------------------------------
--DO NOT EDIT ANYTHING BELOW THIS LINE
-------------------------------------------------------
set toRunPath to do shell script "WINEPREFIX=\"" & winePrefix & "\"; TEMPVAR=\"" & toRun & "\"; echo \"${TEMPVAR%/*}\""
set toRunFile to do shell script "WINEPREFIX=\"" & winePrefix & "\"; TEMPVAR=\"" & toRun & "\"; TEMPVAR2=\"" & toRunPath & "\"; echo \"${TEMPVAR#$TEMPVAR2/}\""
do shell script "PATH=\"" & wineLocation & ":$PATH\"; export WINEPREFIX=\"" & winePrefix & "\"; export DYLD_FALLBACK_LIBRARY_PATH=\"" & dyldFallbackLibraryPath & "\"; cd \"" & toRunPath & "\"; wine \"" & toRunFile & "\" > /dev/null 2>&1 &"
end open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment