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:

committed by
Willow Barraco

parent
5eb481d474
commit
be0bb09739
@@ -20,7 +20,7 @@ sxmo_wm.sh inputevent touchscreen on
|
|||||||
sxmo_wm.sh inputevent stylus on
|
sxmo_wm.sh inputevent stylus on
|
||||||
superctl start sxmo_hook_lisgd
|
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
|
# suspend after if no activity after 120s
|
||||||
sxmo_daemons.sh start idle_locker sxmo_idle.sh -w \
|
sxmo_daemons.sh start idle_locker sxmo_idle.sh -w \
|
||||||
|
@@ -2,25 +2,27 @@
|
|||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
# Copyright 2022 Sxmo Contributors
|
# Copyright 2022 Sxmo Contributors
|
||||||
|
|
||||||
# This hook goal is to setup mutexes if the device must be considered
|
# This hook is called in screenoff, launched as a 10s repeating daemon in
|
||||||
# as idle or not, if it can go to crust or not
|
# screenoff, and also sxmo_autosleep.sh. It will check to see if any custom
|
||||||
|
# things would like to block suspend.
|
||||||
|
#
|
||||||
# include common definitions
|
# include common definitions
|
||||||
# shellcheck source=scripts/core/sxmo_common.sh
|
# shellcheck source=scripts/core/sxmo_common.sh
|
||||||
. sxmo_common.sh
|
. sxmo_common.sh
|
||||||
|
|
||||||
cleanup_main_mutex() {
|
finish() {
|
||||||
sxmo_wakelock.sh unlock checking_mutexes
|
sxmo_wakelock.sh unlock checking_wakelocks
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
exec 3<> "${XDG_RUNTIME_DIR:-$HOME}/sxmo.checkstatemutexes.lock"
|
exec 3<> "${XDG_RUNTIME_DIR:-$HOME}/sxmo.checkwakelocks.lock"
|
||||||
flock -x 3
|
flock -x 3
|
||||||
|
|
||||||
DEFAULT_DURATION=30s # to be sure to not lock indefinitely
|
DEFAULT_DURATION=30s # to be sure to not lock indefinitely
|
||||||
|
|
||||||
sxmo_wakelock.sh lock checking_mutexes "$DEFAULT_DURATION"
|
sxmo_wakelock.sh lock checking_wakelocks "$DEFAULT_DURATION"
|
||||||
trap 'cleanup_main_mutex' TERM INT EXIT
|
|
||||||
|
trap 'finish' TERM INT EXIT
|
||||||
|
|
||||||
# ongoing_call
|
# ongoing_call
|
||||||
if pgrep -f sxmo_modemcall.sh > /dev/null; then
|
if pgrep -f sxmo_modemcall.sh > /dev/null; then
|
@@ -31,14 +31,13 @@ case "$SXMO_WM" in
|
|||||||
;;
|
;;
|
||||||
esac
|
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 (10s) to check wakelocks and go to suspend
|
||||||
# Start a periodic daemon (2s) blink after 5 seconds
|
# Start a periodic daemon (2s) to blink leds
|
||||||
# Resume tasks stop daemons
|
|
||||||
sxmo_daemons.sh start idle_locker sxmo_idle.sh -w \
|
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' \
|
timeout 10 'sxmo_daemons.sh start periodic_wakelock_check sxmo_run_periodically.sh 10 sxmo_hook_wakelocks.sh' \
|
||||||
resume 'sxmo_daemons.sh stop periodic_state_mutex_check'
|
resume 'sxmo_daemons.sh stop periodic_wakelock_check'
|
||||||
|
|
||||||
wait
|
wait
|
||||||
|
|
||||||
|
@@ -11,7 +11,7 @@ set -e
|
|||||||
while true; do
|
while true; do
|
||||||
# Make sure it's fresh before checking locks, reading wakeup_count will
|
# Make sure it's fresh before checking locks, reading wakeup_count will
|
||||||
# block so we can't poll it here
|
# 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
|
# Reading from wakeup_count blocks until there are no wakelocks
|
||||||
wakeup_count=$(cat /sys/power/wakeup_count)
|
wakeup_count=$(cat /sys/power/wakeup_count)
|
||||||
|
Reference in New Issue
Block a user