Skip to content

Commit

Permalink
fix: added potential workaround for failing NSBundle bundleIdentifier…
Browse files Browse the repository at this point in the history
… check in desktop-notifier
  • Loading branch information
ErikBjare committed Nov 27, 2023
1 parent d1d0dec commit c640ee3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions aw_notify/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
and send notifications to the user on predefined conditions.
"""
import logging
import platform
import threading
from collections import defaultdict
from datetime import datetime, timedelta, timezone
Expand Down Expand Up @@ -252,6 +253,16 @@ def main(ctx, verbose: bool, testing: bool):
logging.getLogger("urllib3").setLevel(logging.WARNING)
logger.info("Starting...")

# set NSBundle on macOS, needed for desktop-notifier
if platform.system() == "Darwin":
from rubicon.objc import ObjCClass

# needs to be the same as the one in the PyInstaller config (later Info.plist)
# could also be done by just monkey-patching the helper function is_signed_bundle in desktop-notifier
# see: https://github.com/samschott/desktop-notifier/issues/115
NSBundle = ObjCClass("NSBundle")
NSBundle.mainBundle.bundleIdentifier = "net.activitywatch.ActivityWatch"

if ctx.invoked_subcommand is None:
ctx.invoke(start)

Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ aw-notify = "aw_notify.main:main"
python = "^3.9,<3.12"
aw-client = "^0.5.13"
desktop-notifier = "^3.4.2"
rubicon-objc = { version = "^0.4.0", platform = "darwin" }

[tool.poetry.group.dev.dependencies]
black = "*"
Expand Down

0 comments on commit c640ee3

Please sign in to comment.