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 a66976a84b2174f172cd0f0103e963172af5460c
parent d27f3b3935e096b9abac9ec790971d1d34d43078
Author: JayVii <jayvii@posteo.de>
Date:   Thu, 19 Aug 2021 23:27:16 +0200

Merge branch 'main' of https://src.jayvii.de/Hobby/PinePhoneScripts

Diffstat:
Msguard/README.md | 2+-
Asxmo/hooks/lock | 45+++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/sguard/README.md b/sguard/README.md @@ -35,7 +35,7 @@ unable to trigger the suspend-inhibit. Just download this source directory, and run the Makefile: ``` -git pull https://src.jayvii.de/Hobby/PinePhoneScripts +git clone https://src.jayvii.de/Hobby/PinePhoneScripts cd PinePhoneScripts/sguard make install ``` 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