Skip to content

Commit 1f4d036

Browse files
committed
feat: added proper icon and media submodule
1 parent d9e2e28 commit 1f4d036

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "media"]
2+
path = media
3+
url = https://github.com/ActivityWatch/media.git

aw_notify/main.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ def to_hms(duration: timedelta) -> str:
9393

9494
notifier: DesktopNotifier = None
9595

96+
# executable path
97+
from pathlib import Path
98+
99+
script_dir = Path(__file__).parent.absolute()
100+
icon_path = script_dir / ".." / "media" / "logo" / "logo.png"
101+
96102

97103
def notify(title: str, msg: str):
98104
# send a notification to the user
@@ -101,11 +107,11 @@ def notify(title: str, msg: str):
101107
if notifier is None:
102108
notifier = DesktopNotifier(
103109
app_name="ActivityWatch",
104-
# icon="file:///path/to/icon.png",
110+
app_icon=f"file://{icon_path}",
105111
notification_limit=10,
106112
)
107113

108-
print(msg)
114+
logger.info(f'Showing: "{title} - {msg}"')
109115
notifier.send_sync(title=title, message=msg)
110116

111117

@@ -174,7 +180,7 @@ def check(self):
174180
self.max_triggered = thres
175181
notify(
176182
"Time spent",
177-
f"{self.category or 'All'}: {to_hms(self.time_spent)}",
183+
f"{self.category or 'All'}: {to_hms(thres)} reached! ({to_hms(self.time_spent)})",
178184
)
179185
break
180186

@@ -210,7 +216,7 @@ def threshold_alerts():
210216
Checks elapsed time for each category and triggers alerts when thresholds are reached.
211217
"""
212218
alerts = [
213-
CategoryAlert("", [td15min, td30min, td1h, td2h, td4h, td6h, td8h]),
219+
CategoryAlert("", [td1h, td2h, td4h, td6h, td8h]),
214220
CategoryAlert("Twitter", [td15min, td30min, td1h]),
215221
CategoryAlert("Work", [td15min, td30min, td1h, td2h, td4h]),
216222
]
@@ -221,7 +227,7 @@ def threshold_alerts():
221227
alert.check()
222228
status = alert.status()
223229
if status != getattr(alert, "last_status", None):
224-
print(f"New status: {status}")
230+
logger.info(f"New status: {status}")
225231
alert.last_status = status
226232

227233
sleep(10)

media

Submodule media added at ae8d373

0 commit comments

Comments
 (0)