Skip to content

Commit 08c39d0

Browse files
committed
Bypass main power check when dismissing the notification
1 parent 8255a55 commit 08c39d0

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

cron_notify.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ class CronNotify(object):
4747
_sleepTime = 3600
4848
_mainPower = False
4949

50+
_bypassMainPower = False
51+
5052
_cacheFile = None
5153

5254
_lastExecution = None
@@ -426,7 +428,7 @@ def _resumeCallback(self, isPreparing):
426428
def _wait(self):
427429
try:
428430
if self._waitUntilScheduled():
429-
if not self._mainPower or self._waitUntilMainPower():
431+
if self._waitUntilMainPower():
430432
self._initNotification()
431433

432434
self._notificationTimeout(self._sleepTime)
@@ -482,6 +484,13 @@ def _timeoutCallback(self):
482484
return False
483485

484486
def _waitUntilMainPower(self):
487+
if self._bypassMainPower:
488+
self._bypassMainPower = False
489+
return True
490+
491+
if not self._mainPower:
492+
return True
493+
485494
try:
486495
upower = self._bus.get_object("org.freedesktop.UPower", "/org/freedesktop/UPower")
487496
onBattery = upower.Get("org.freedesktop.UPower", "OnBattery", dbus_interface=dbus.PROPERTIES_IFACE)
@@ -560,6 +569,8 @@ def _notificationCloseCallback(self, notification):
560569

561570
if self._notificationAction is None:
562571
self._logger.info("User dismissed the notification")
572+
573+
self._bypassMainPower = True
563574
elif self._notificationAction == "later":
564575
self._logger.info("User requested to notify again later")
565576

0 commit comments

Comments
 (0)