Skip to content

Instantly share code, notes, and snippets.

@mattintosh4
Last active December 16, 2015 04:09
Show Gist options
  • Save mattintosh4/5375108 to your computer and use it in GitHub Desktop.
Save mattintosh4/5375108 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# OS X Wine.app creator
# Copyright (c) 2013 mattintosh4, http://mattintosh.hatenablog.com
#
# usage:
# bash wine_application_bundle_creator.sh /opt/local/bin/wine
#
test -x "$1" || { echo "WINELOADER is not found. Please set argument to WINELOADER path."; exit; }
osacompile -o Wine.app <<__APPLESCRIPT__
property WINELOADER : "$1"
on main(input)
try
do shell script WINELOADER & space & input
-- If you use XQuartz fontconfig file
-- do shell script "FONTCONFIG_PATH=/opt/X11/lib/X11/fontconfig" & space & WINELOADER & space & input
end try
end main
on open argv
repeat with aFile in argv
main("start /Unix" & space & quoted form of (POSIX path of aFile))
end repeat
end open
on run
main("explorer")
end run
__APPLESCRIPT__
while read
do
/usr/libexec/PlistBuddy -c "${REPLY}" Wine.app/Contents/Info.plist
done <<__CMD__
Add :CFBundleDocumentTypes:1:CFBundleTypeExtensions array
Add :CFBundleDocumentTypes:1:CFBundleTypeExtensions:0 string exe
Add :CFBundleDocumentTypes:1:CFBundleTypeName string Windows Executable File
Add :CFBundleDocumentTypes:1:CFBundleTypeRole string Viewer
Add :CFBundleDocumentTypes:2:CFBundleTypeExtensions array
Add :CFBundleDocumentTypes:2:CFBundleTypeExtensions:0 string msi
Add :CFBundleDocumentTypes:2:CFBundleTypeName string Microsoft Windows Installer
Add :CFBundleDocumentTypes:2:CFBundleTypeRole string Viewer
Add :CFBundleDocumentTypes:3:CFBundleTypeExtensions array
Add :CFBundleDocumentTypes:3:CFBundleTypeExtensions:0 string lnk
Add :CFBundleDocumentTypes:3:CFBundleTypeName string Windows Shortcut File
Add :CFBundleDocumentTypes:3:CFBundleTypeRole string Viewer
__CMD__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment