pinephone-scripts

Scripts and small applications for the PinePhone
git clone https://src.jayvii.de/pub/pinephone-scripts.git
Log | Files | Refs | README | LICENSE

commit 025ae7678bd4016bb4dffa87867b8e0eaa6b4673
parent 05614554ec41601dabdec95813e294f03c3acc96
Author: JayVii <jayvii@noreply.localhost>
Date:   Tue, 29 Jun 2021 14:34:58 +0200

Add locking hook

Diffstat:
Asxmo/hooks/lock | 45+++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+), 0 deletions(-)

diff --git a/sxmo/hooks/lock b/sxmo/hooks/lock @@ -0,0 +1,44 @@ +#!/usr/bin/env sh + +function suspend_after_x() { + + # Initial timeout + sleep $1 + + # As long as media is running / sound is playing, do not suspend. + while [ $(check_player_state) == "true" ]; do + sleep $1 + done + + # If screen is locked, suspend immediately again. + if [ ! -z $(pidof sxmo_screenlock) ]; then + #pkill -9 sxmo_screenlock # probably not necessary... + if [ -z $SXMO_RTCWAKEINTERVAL ]; then + sxmo_screenlock --suspend + else + sxmo_screenlock --suspend --wake-interval $SXMO_RTCWAKEINTERVAL + fi + fi + + # Post wake: reset backlight again + sxmo_setpinebacklight $2 +} + +function check_player_state { + if [[ -z $(pacmd list-sink-inputs | grep "state: RUNNING$") ]]; then + echo false + else + echo true + fi +} + +# Current backlight? +CUR_BL=$(cat /sys/class/backlight/backlight/brightness) + +SXMO_LOCK_SUSPEND_AFTER_X=30 # that should be in .profile or .xinitrc + +if [! -z $SXMO_LOCK_SUSPEND_AFTER_X ]; then + suspend_after_x $SXMO_LOCK_SUSPEND_AFTER_X $CUR_BL & +fi + +# EOF lock +\ No newline at end of file