cleanup check_state_mutex (rename to wakelock)

Mostly a cleanup. We now have sxmo_wakeup.sh so the hook should bear
that name somehow (although sxmo_hook_suspendblockers might fit too)

Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
This commit is contained in:
Peter John Hartman
2023-03-11 04:23:39 -06:00
committed by Willow Barraco
parent 5eb481d474
commit be0bb09739
4 changed files with 17 additions and 16 deletions

View File

@@ -20,7 +20,7 @@ sxmo_wm.sh inputevent touchscreen on
sxmo_wm.sh inputevent stylus on
superctl start sxmo_hook_lisgd
sxmo_daemons.sh start periodic_state_mutex_check sxmo_run_periodically.sh 10 sxmo_hook_check_state_mutexes.sh
sxmo_daemons.sh start periodic_wakelock_check sxmo_run_periodically.sh 10 sxmo_hook_wakelocks.sh
# suspend after if no activity after 120s
sxmo_daemons.sh start idle_locker sxmo_idle.sh -w \

View File

@@ -2,25 +2,27 @@
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
# This hook goal is to setup mutexes if the device must be considered
# as idle or not, if it can go to crust or not
# This hook is called in screenoff, launched as a 10s repeating daemon in
# screenoff, and also sxmo_autosleep.sh. It will check to see if any custom
# things would like to block suspend.
#
# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh
cleanup_main_mutex() {
sxmo_wakelock.sh unlock checking_mutexes
finish() {
sxmo_wakelock.sh unlock checking_wakelocks
exit 0
}
exec 3<> "${XDG_RUNTIME_DIR:-$HOME}/sxmo.checkstatemutexes.lock"
exec 3<> "${XDG_RUNTIME_DIR:-$HOME}/sxmo.checkwakelocks.lock"
flock -x 3
DEFAULT_DURATION=30s # to be sure to not lock indefinitely
sxmo_wakelock.sh lock checking_mutexes "$DEFAULT_DURATION"
trap 'cleanup_main_mutex' TERM INT EXIT
sxmo_wakelock.sh lock checking_wakelocks "$DEFAULT_DURATION"
trap 'finish' TERM INT EXIT
# ongoing_call
if pgrep -f sxmo_modemcall.sh > /dev/null; then

View File

@@ -31,14 +31,13 @@ case "$SXMO_WM" in
;;
esac
sxmo_hook_check_state_mutexes.sh
sxmo_hook_wakelocks.sh
# Start a periodic daemon (8s) "try to go to crust" after 8 seconds
# Start a periodic daemon (2s) blink after 5 seconds
# Resume tasks stop daemons
# Start a periodic daemon (10s) to check wakelocks and go to suspend
# Start a periodic daemon (2s) to blink leds
sxmo_daemons.sh start idle_locker sxmo_idle.sh -w \
timeout 10 'sxmo_daemons.sh start periodic_state_mutex_check sxmo_run_periodically.sh 10 sxmo_hook_check_state_mutexes.sh' \
resume 'sxmo_daemons.sh stop periodic_state_mutex_check'
timeout 10 'sxmo_daemons.sh start periodic_wakelock_check sxmo_run_periodically.sh 10 sxmo_hook_wakelocks.sh' \
resume 'sxmo_daemons.sh stop periodic_wakelock_check'
wait

View File

@@ -11,7 +11,7 @@ set -e
while true; do
# Make sure it's fresh before checking locks, reading wakeup_count will
# block so we can't poll it here
sxmo_hook_check_state_mutexes.sh
sxmo_hook_wakelocks.sh
# Reading from wakeup_count blocks until there are no wakelocks
wakeup_count=$(cat /sys/power/wakeup_count)