Files
sxmo-utils/configs/default_hooks/three_button_touchscreen/sxmo_hook_lock.sh
Willow Barraco ef8254681c Unify sxmo state switch and ensure consistency
If two power handler trigger at the same time, the current behavior is
that we switch two time to the same target state.

This move the flock to a central script that make sure only one switch
is ocurring at the same time. Concurrent switch will wait for the
previous one to finish before guessing the new target state.

This also refactorise the sxmo_proximitylock.sh to make it simple,
stripping the two related proximitylock and proximityunlock states.

Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
Signed-off-by: Anjandev Momi <anjan@momi.ca>
2023-09-09 12:47:04 -07:00

37 lines
928 B
Bash
Executable File

#!/bin/sh
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
#
# See man 7 sxmo.states.
#
# This will:
# - blink blue led once
# - turn screen on
# - disable input
# - set up a daemon to automatically transition to screenoff state after 8s.
# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh
sxmo_wakelock.sh lock sxmo_not_screenoff infinite
# This hook is called when the system reaches a locked state
sxmo_led.sh blink blue &
[ "$SXMO_WM" = "sway" ] && swaymsg mode default
sxmo_wm.sh dpms off
sxmo_wm.sh inputevent touchscreen off
sxmo_daemons.sh stop periodic_blink
sxmo_daemons.sh stop periodic_wakelock_check
# Go to screenoff after 8 seconds of inactivity
if ! [ -e "$XDG_CACHE_HOME/sxmo/sxmo.noidle" ]; then
sxmo_daemons.sh start idle_locker sxmo_idle.sh -w \
timeout "${SXMO_LOCK_IDLE_TIME:-8}" "sxmo_state_switch.sh set screenoff"
fi
wait