mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-21 08:01:31 +00:00
aw-notify: fix Darwin build
Assisted-by: Codex:gpt-5.5
(cherry picked from commit f403883c2d)
This commit is contained in:
committed by
github-actions[bot]
parent
9dde6d6888
commit
61ea2bb237
@@ -0,0 +1,72 @@
|
||||
diff --git a/aw_notify/main.py b/aw_notify/main.py
|
||||
index c749725..44dce5a 100644
|
||||
--- a/aw_notify/main.py
|
||||
+++ b/aw_notify/main.py
|
||||
@@ -3,6 +3,7 @@
|
||||
and send notifications to the user on predefined conditions.
|
||||
"""
|
||||
|
||||
+import asyncio
|
||||
import logging
|
||||
import sys
|
||||
import threading
|
||||
@@ -23,7 +24,7 @@
|
||||
import aw_client.queries
|
||||
import click
|
||||
from aw_core.log import setup_logging
|
||||
-from desktop_notifier import DesktopNotifier
|
||||
+from desktop_notifier import DesktopNotifier, Icon
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -149,11 +150,20 @@ def notify(title: str, msg: str):
|
||||
if notifier is None:
|
||||
notifier = DesktopNotifier(
|
||||
app_name="AW",
|
||||
- app_icon=f"file://{icon_path}",
|
||||
+ app_icon=Icon(uri=f"file://{icon_path}"),
|
||||
notification_limit=10,
|
||||
)
|
||||
|
||||
logger.info(f'Showing: "{title} - {msg}"')
|
||||
- notifier.send_sync(title=title, message=msg)
|
||||
+
|
||||
+ # Get or create event loop
|
||||
+ try:
|
||||
+ loop = asyncio.get_running_loop()
|
||||
+ except RuntimeError:
|
||||
+ loop = asyncio.new_event_loop()
|
||||
+ asyncio.set_event_loop(loop)
|
||||
+
|
||||
+ # Send notification
|
||||
+ loop.run_until_complete(notifier.send(title=title, message=msg))
|
||||
|
||||
|
||||
class CategoryAlert:
|
||||
diff --git a/pyproject.toml b/pyproject.toml
|
||||
index 314fe2f..0d6d5a9 100644
|
||||
--- a/pyproject.toml
|
||||
+++ b/pyproject.toml
|
||||
@@ -13,15 +13,15 @@ packages = [{include = "aw_notify"}]
|
||||
aw-notify = "aw_notify.main:main"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
-python = "^3.9,<3.12"
|
||||
-aw-client = "^0.5.13"
|
||||
-desktop-notifier = "^3.4.2"
|
||||
-rubicon-objc = { version = "^0.4.0", platform = "darwin" }
|
||||
+python = ">=3.9,<3.14"
|
||||
+aw-client = "^0.5.15"
|
||||
+desktop-notifier = "^6.0.0"
|
||||
+rubicon-objc = { version = "^0.5.0", platform = "darwin" }
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
black = "*"
|
||||
mypy = "*"
|
||||
-pyinstaller = "^6.6"
|
||||
-pytest = "^7.4"
|
||||
+pyinstaller = "^6.12.0"
|
||||
+pytest = "*"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
@@ -159,6 +159,12 @@ rec {
|
||||
pyproject = true;
|
||||
build-system = [ python3Packages.poetry-core ];
|
||||
|
||||
patches = [
|
||||
# Backport desktop-notifier 6 / rubicon-objc 0.5 support.
|
||||
# https://github.com/ActivityWatch/aw-notify/pull/10
|
||||
./aw-notify-desktop-notifier-6.patch
|
||||
];
|
||||
|
||||
dependencies = with python3Packages; [
|
||||
aw-client
|
||||
desktop-notifier
|
||||
|
||||
Reference in New Issue
Block a user