diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2022-03-04 22:31:09 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2022-03-04 22:31:09 +0100 |
| commit | 312bc6955ac36197c9069d28dbfe234bae76e39d (patch) | |
| tree | 3ddd76db1478313ec3bb3a1d98a2648129108907 | |
| parent | b24bfb10c7cb50386bff19e699d5bc0e44382770 (diff) | |
Do not suspend on active inhibitors
| -rw-r--r-- | sleepwalk | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -23,7 +23,7 @@ wait_for_notifications() { is_led_on=0 fi - if is_screen_on; then + if is_screen_on_or_inhibitor_active; then break fi secs=$(($secs-1)) @@ -40,7 +40,15 @@ reset_wake_time() { > /sys/class/rtc/rtc0/wakealarm } -is_screen_on() { +is_screen_on_or_inhibitor_active() { + INHIBITORS=$(systemd-inhibit --list --no-legend \ + | grep -e '[[:space:]]sleep[[:space:]]' \ + | grep -e 'lock$') + + if [ "$INHIBITORS" != "" ]; then + return 0 + fi + return "$(cat /sys/class/backlight/backlight/bl_power)" } @@ -85,7 +93,7 @@ if [ "$1" == "start" ]; then trap "$0 stop" EXIT while [ -d "$LOCK_DIR" ]; do - while is_screen_on; do + while is_screen_on_or_inhibitor_active; do sleep 60 done @@ -97,7 +105,7 @@ if [ "$1" == "start" ]; then echo "Failed going to sleep, try again in $WAKE_SECS seconds ..." >&2 wait_for_notifications schedule_wake_time - if is_screen_on; then + if is_screen_on_or_inhibitor_active; then break fi done |
