Skip to content

Commit

Permalink
osx: Fix notifications not showing as from Plover
Browse files Browse the repository at this point in the history
- Extract the Python binary from the bundled Python.app
- Unsign it so that our custom PList is respected

Co-authored-by: Benoit Pierre <[email protected]>
  • Loading branch information
morinted and benoit-pierre committed Apr 18, 2021
1 parent e454251 commit 340861b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ nosetests.xml
.idea
.cache

# VSCode
.vscode

#Mr Developer
.mr.developer.cfg

Expand Down
1 change: 1 addition & 0 deletions news.d/bugfix/1271.osx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Mac notifications no longer have "Plover" as their title.
3 changes: 2 additions & 1 deletion osx/app_resources/dist_blacklist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
:
_CodeSignature
share
Resources/English.lproj
Resources
:bin
!python
!python3*
!Info.plist
*
:lib
**/*.tcl
Expand Down
18 changes: 18 additions & 0 deletions osx/make_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>org.openstenoproject.plover</string>
</dict>
</plist>
EOF

# Switch to target Python.
SSL_CERT_FILE="$("$python" -m certifi)"
run_eval "appdir_python() { env PYTHONNOUSERSITE=1 "$py_home/bin/python" \"\$@\"; }"
Expand Down
3 changes: 1 addition & 2 deletions plover/oslayer/log_osx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 340861b

Please sign in to comment.