@@ -93,6 +93,12 @@ def to_hms(duration: timedelta) -> str:
93
93
94
94
notifier : DesktopNotifier = None
95
95
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
+
96
102
97
103
def notify (title : str , msg : str ):
98
104
# send a notification to the user
@@ -101,11 +107,11 @@ def notify(title: str, msg: str):
101
107
if notifier is None :
102
108
notifier = DesktopNotifier (
103
109
app_name = "ActivityWatch" ,
104
- # icon= "file:///path/to/icon.png ",
110
+ app_icon = f "file://{ icon_path } " ,
105
111
notification_limit = 10 ,
106
112
)
107
113
108
- print ( msg )
114
+ logger . info ( f'Showing: " { title } - { msg } "' )
109
115
notifier .send_sync (title = title , message = msg )
110
116
111
117
@@ -174,7 +180,7 @@ def check(self):
174
180
self .max_triggered = thres
175
181
notify (
176
182
"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 )} ) " ,
178
184
)
179
185
break
180
186
@@ -210,7 +216,7 @@ def threshold_alerts():
210
216
Checks elapsed time for each category and triggers alerts when thresholds are reached.
211
217
"""
212
218
alerts = [
213
- CategoryAlert ("" , [td15min , td30min , td1h , td2h , td4h , td6h , td8h ]),
219
+ CategoryAlert ("" , [td1h , td2h , td4h , td6h , td8h ]),
214
220
CategoryAlert ("Twitter" , [td15min , td30min , td1h ]),
215
221
CategoryAlert ("Work" , [td15min , td30min , td1h , td2h , td4h ]),
216
222
]
@@ -221,7 +227,7 @@ def threshold_alerts():
221
227
alert .check ()
222
228
status = alert .status ()
223
229
if status != getattr (alert , "last_status" , None ):
224
- print (f"New status: { status } " )
230
+ logger . info (f"New status: { status } " )
225
231
alert .last_status = status
226
232
227
233
sleep (10 )
0 commit comments