@@ -47,6 +47,8 @@ class CronNotify(object):
47
47
_sleepTime = 3600
48
48
_mainPower = False
49
49
50
+ _bypassMainPower = False
51
+
50
52
_cacheFile = None
51
53
52
54
_lastExecution = None
@@ -426,7 +428,7 @@ def _resumeCallback(self, isPreparing):
426
428
def _wait (self ):
427
429
try :
428
430
if self ._waitUntilScheduled ():
429
- if not self . _mainPower or self ._waitUntilMainPower ():
431
+ if self ._waitUntilMainPower ():
430
432
self ._initNotification ()
431
433
432
434
self ._notificationTimeout (self ._sleepTime )
@@ -482,6 +484,13 @@ def _timeoutCallback(self):
482
484
return False
483
485
484
486
def _waitUntilMainPower (self ):
487
+ if self ._bypassMainPower :
488
+ self ._bypassMainPower = False
489
+ return True
490
+
491
+ if not self ._mainPower :
492
+ return True
493
+
485
494
try :
486
495
upower = self ._bus .get_object ("org.freedesktop.UPower" , "/org/freedesktop/UPower" )
487
496
onBattery = upower .Get ("org.freedesktop.UPower" , "OnBattery" , dbus_interface = dbus .PROPERTIES_IFACE )
@@ -560,6 +569,8 @@ def _notificationCloseCallback(self, notification):
560
569
561
570
if self ._notificationAction is None :
562
571
self ._logger .info ("User dismissed the notification" )
572
+
573
+ self ._bypassMainPower = True
563
574
elif self ._notificationAction == "later" :
564
575
self ._logger .info ("User requested to notify again later" )
565
576
0 commit comments