diff --git a/build_macos.sh b/build_macos.sh new file mode 100644 index 0000000..8abe1d6 --- /dev/null +++ b/build_macos.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# build .app for mac +python setup.py bdist_mac + +# copy shell script to .app +for DIR in ./build/ReticulumWebChat-*.app/Contents/MacOS; do + cp ./macos/ReticulumWebChat.sh "$DIR/ReticulumWebChat.sh" + chmod +x "$DIR/ReticulumWebChat.sh" +done + +# todo codesign? diff --git a/macos/ReticulumWebChat.sh b/macos/ReticulumWebChat.sh new file mode 100644 index 0000000..49ca617 --- /dev/null +++ b/macos/ReticulumWebChat.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +# references for making a macOS .app that runs a shell script +# https://apple.stackexchange.com/a/407885 +# https://github.com/Whisky-App/Whisky/issues/107#issuecomment-1592934039 +# https://stackoverflow.com/a/71875958 +# https://stackoverflow.com/a/5756763 + +# get path to directory where this script is currently executing from +# we are expecting this to be "ReticulumWebChat.app/Contents/MacOS" +ABSPATH=$(cd "$(dirname "$0")"; pwd -P) + +# path to the actual executable that we want to run as a console application (via Terminal) +EXE="$ABSPATH/ReticulumWebChat" + +# open actual executable in terminal +# we also provide a custom storage dir within the user home directory +osascript -e " + tell app \"Terminal\" + do script \"$EXE --storage-dir ~/.reticulum-webchat; exit $?\" + activate + end tell +" diff --git a/macos/icon.icns b/macos/icon.icns new file mode 100644 index 0000000..b0b3498 Binary files /dev/null and b/macos/icon.icns differ diff --git a/setup.py b/setup.py index 19d8f3b..728ec79 100644 --- a/setup.py +++ b/setup.py @@ -41,5 +41,12 @@ setup( # use a static upgrade code to allow installer to remove existing files on upgrade 'upgrade_code': '{6c69616d-ae73-460c-88e8-399b3134134e}', }, + 'bdist_mac': { + 'iconfile': "macos/icon.icns", + 'plist_items': [ + # we want ReticulumWebChat.app to execute ReticulumWebChat.sh instead of the python binary, as we need to launch it via terminal + ('CFBundleExecutable', 'ReticulumWebChat.sh'), + ], + }, }, )