From 352eb18a14aa84f09126884866806dc1fc40fe23 Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 26 Aug 2021 12:29:31 +0200 Subject: [PATCH 1/2] feat: allow suspend without wakeup time addresses #22 --- etc/autosuspend | 3 +++ usr/local/sbin/autosuspend.main | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/etc/autosuspend b/etc/autosuspend index 151df08..20bca86 100644 --- a/etc/autosuspend +++ b/etc/autosuspend @@ -10,6 +10,9 @@ DONT_SUSPEND_BY_DAY='no' # Automatically reboot once a week when the system isn't in use REBOOT_ONCE_PER_WEEK='yes' +# Allow suspend when no wakeup time exists +SUSPEND_WITHOUT_WAKEUP='no' + # Daemons that always have one process running, only if more that one process is active we prevent the suspend # The values are used with grep, so just a unique portion is sufficient DAEMONS='' diff --git a/usr/local/sbin/autosuspend.main b/usr/local/sbin/autosuspend.main index 88512c9..a8b817a 100755 --- a/usr/local/sbin/autosuspend.main +++ b/usr/local/sbin/autosuspend.main @@ -132,6 +132,10 @@ if [ "$AUTO_SUSPEND" = "true" ] || [ "$AUTO_SUSPEND" = "yes" ] ; then logit "Suspend method: $suspend_method" SetWakeupTime wakeup_time=$(cat /sys/class/rtc/rtc0/wakealarm) + if [[ -z "$wakeup_time" ]] && [[ "${SUSPEND_WITHOUT_WAKEUP:-no}" != "yes" ]]; then + logit "Aborting suspend because of missing wakeup time" + exit 3 + fi if [[ "$wakeup_time" -le $(date +%s) ]]; then logit "Aborting suspend because wakeup time" $(date --date @$wakeup_time) "is in the past" exit 2 From 73cf6dfe53afa0d5e0d0d61e1590d8cd6bf01a0d Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 26 Aug 2021 12:39:00 +0200 Subject: [PATCH 2/2] feat: allow suspend without wakeup time addresses #22 --- usr/local/sbin/autosuspend.main | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/sbin/autosuspend.main b/usr/local/sbin/autosuspend.main index a8b817a..cc6859e 100755 --- a/usr/local/sbin/autosuspend.main +++ b/usr/local/sbin/autosuspend.main @@ -136,7 +136,7 @@ if [ "$AUTO_SUSPEND" = "true" ] || [ "$AUTO_SUSPEND" = "yes" ] ; then logit "Aborting suspend because of missing wakeup time" exit 3 fi - if [[ "$wakeup_time" -le $(date +%s) ]]; then + if [[ -n "$wakeup_time" ]] && [[ "$wakeup_time" -le $(date +%s) ]]; then logit "Aborting suspend because wakeup time" $(date --date @$wakeup_time) "is in the past" exit 2 fi