From 340861bcd37193e4ad11b8b569c873de32f3b94a Mon Sep 17 00:00:00 2001 From: Ted Morin Date: Sun, 18 Apr 2021 18:45:06 -0400 Subject: [PATCH] osx: Fix notifications not showing as from Plover - Extract the Python binary from the bundled Python.app - Unsign it so that our custom PList is respected Co-authored-by: Benoit Pierre --- .gitignore | 3 +++ news.d/bugfix/1271.osx.md | 1 + osx/app_resources/dist_blacklist.txt | 3 ++- osx/make_app.sh | 18 ++++++++++++++++++ plover/oslayer/log_osx.py | 3 +-- 5 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 news.d/bugfix/1271.osx.md diff --git a/.gitignore b/.gitignore index 9bfca038c..74a44ffbb 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,9 @@ nosetests.xml .idea .cache +# VSCode +.vscode + #Mr Developer .mr.developer.cfg diff --git a/news.d/bugfix/1271.osx.md b/news.d/bugfix/1271.osx.md new file mode 100644 index 000000000..d213102be --- /dev/null +++ b/news.d/bugfix/1271.osx.md @@ -0,0 +1 @@ +Mac notifications no longer have "Plover" as their title. diff --git a/osx/app_resources/dist_blacklist.txt b/osx/app_resources/dist_blacklist.txt index 7bf434ead..0c1b3ce0d 100644 --- a/osx/app_resources/dist_blacklist.txt +++ b/osx/app_resources/dist_blacklist.txt @@ -2,10 +2,11 @@ : _CodeSignature share - Resources/English.lproj + Resources :bin !python !python3* + !Info.plist * :lib **/*.tcl diff --git a/osx/make_app.sh b/osx/make_app.sh index cc5e5c285..e39e8ea75 100644 --- a/osx/make_app.sh +++ b/osx/make_app.sh @@ -30,6 +30,24 @@ run mkdir -p "$frameworks_dir" "$resources_dir" "$macos_dir" # Create the Python framework. run osx_standalone_python "$frameworks_dir" "$py_installer_version" "$py_installer_macos" "$py_installer_sha1" "$reloc_py_url" "$reloc_py_sha1" +py_binary="$py_home/bin/python${py_version%.*}" + +# Extract Python binary from launcher and fix its references. +run mv "$py_home/Resources/Python.app/Contents/MacOS/Python" "$py_binary" +run install_name_tool -rpath "@executable_path/../../../../../../" "@executable_path/../../../" "$py_binary" +# Remove the codesignature so that we can change the identifier for notifications. +run /usr/bin/codesign -s - --deep --force "$py_binary" +run tee "$py_home/bin/Info.plist" <<\EOF + + + + + CFBundleIdentifier + org.openstenoproject.plover + + +EOF + # Switch to target Python. SSL_CERT_FILE="$("$python" -m certifi)" run_eval "appdir_python() { env PYTHONNOUSERSITE=1 "$py_home/bin/python" \"\$@\"; }" diff --git a/plover/oslayer/log_osx.py b/plover/oslayer/log_osx.py index 7276f7b12..f138d2ba7 100644 --- a/plover/oslayer/log_osx.py +++ b/plover/oslayer/log_osx.py @@ -19,8 +19,7 @@ def emit(self, record): # Notification Center has no levels or timeouts. notification = NSUserNotification.alloc().init() - notification.setTitle_(__software_name__.capitalize()) - notification.setSubtitle_(record.levelname.title()) + notification.setTitle_(record.levelname.title()) notification.setInformativeText_(self.format(record)) ns = NSUserNotificationCenter.defaultUserNotificationCenter()