Handle cron tasks while in crust
mnc goal is to display when will occurs the next cron job. We drop the "sxmo_screenlock.sh rtc" command and the SXMO_RTCWAKEINTERVAL variable. We will now only use "sxmo_screenlock.sh crust" which mean suspend until next cron job (-2 seconds). To replicate the old behavior of the blinking phone then returning to suspension (if needed) we now use a new script. By example: */15 * * * * DISPLAY=:0 sxmo_rtcwake.sh sleep 10 This will trigger a 10s sleep task every 15 minutes (the old default rtcwake hook). Signed-off-by: Stacy Harper <contact@stacyharper.net> Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
This commit is contained in:
parent
02a37c9dea
commit
0ed27f8538
6 changed files with 54 additions and 107 deletions
|
@ -48,10 +48,6 @@ command -v firefox && export BROWSER=firefox
|
||||||
# Prepopulate Subreddits menu with custom subreddits
|
# Prepopulate Subreddits menu with custom subreddits
|
||||||
#export SXMO_SUBREDDITS="postmarketos pinephoneOfficial pinephone unixporn"
|
#export SXMO_SUBREDDITS="postmarketos pinephoneOfficial pinephone unixporn"
|
||||||
|
|
||||||
# Temporarily wake every 5 minutes during sleep
|
|
||||||
#(useful for getting notifications)
|
|
||||||
#export SXMO_RTCWAKEINTERVAL=300
|
|
||||||
|
|
||||||
# Change the default terminal command
|
# Change the default terminal command
|
||||||
# export TERMCMD="st -e"
|
# export TERMCMD="st -e"
|
||||||
|
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
#!/usr/bin/env sh
|
|
||||||
|
|
||||||
. "$(which sxmo_common.sh)"
|
|
||||||
|
|
||||||
REDLED_PATH="/sys/class/leds/red:indicator/brightness"
|
|
||||||
BLUELED_PATH="/sys/class/leds/blue:indicator/brightness"
|
|
||||||
|
|
||||||
finish() {
|
|
||||||
kill $BLINKPID
|
|
||||||
|
|
||||||
echo 0 > "$REDLED_PATH"
|
|
||||||
echo 0 > "$BLUELED_PATH"
|
|
||||||
|
|
||||||
# Going back to crust
|
|
||||||
if [ "$(sxmo_screenlock.sh getCurState)" != "unlock" ]; then
|
|
||||||
sxmo_screenlock.sh rtc "$SXMO_RTCWAKEINTERVAL"
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
trap 'finish' TERM INT EXIT
|
|
||||||
|
|
||||||
blink() {
|
|
||||||
while [ "$(sxmo_screenlock.sh getCurState)" != "unlock" ]; do
|
|
||||||
echo 1 > "$REDLED_PATH"
|
|
||||||
echo 0 > "$BLUELED_PATH"
|
|
||||||
sleep 0.5
|
|
||||||
echo 0 > "$REDLED_PATH"
|
|
||||||
echo 1 > "$BLUELED_PATH"
|
|
||||||
sleep 0.5
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
blink &
|
|
||||||
BLINKPID=$!
|
|
||||||
|
|
||||||
# Replace this by wathever you want to do
|
|
||||||
sleep 10
|
|
|
@ -9,6 +9,8 @@
|
||||||
# we disable shellcheck SC2034 (variable not used)
|
# we disable shellcheck SC2034 (variable not used)
|
||||||
# for all the variables we define here
|
# for all the variables we define here
|
||||||
|
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-$HOME/.local/run}"
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
export NOTIFDIR="$XDG_DATA_HOME"/sxmo/notifications
|
export NOTIFDIR="$XDG_DATA_HOME"/sxmo/notifications
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
|
|
|
@ -9,14 +9,6 @@ ACTION="$1"
|
||||||
# shellcheck source=scripts/core/sxmo_common.sh
|
# shellcheck source=scripts/core/sxmo_common.sh
|
||||||
. "$(dirname "$0")/sxmo_common.sh"
|
. "$(dirname "$0")/sxmo_common.sh"
|
||||||
|
|
||||||
crust() {
|
|
||||||
if [ -n "$SXMO_RTCWAKEINTERVAL" ]; then
|
|
||||||
sxmo_screenlock.sh rtc "$SXMO_RTCWAKEINTERVAL"
|
|
||||||
else
|
|
||||||
sxmo_screenlock.sh crust
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
lock_screen() {
|
lock_screen() {
|
||||||
if [ "$SXMO_LOCK_SCREEN_OFF" = "1" ]; then
|
if [ "$SXMO_LOCK_SCREEN_OFF" = "1" ]; then
|
||||||
sxmo_screenlock.sh off
|
sxmo_screenlock.sh off
|
||||||
|
@ -24,7 +16,7 @@ lock_screen() {
|
||||||
sxmo_screenlock.sh lock
|
sxmo_screenlock.sh lock
|
||||||
fi
|
fi
|
||||||
if [ "$SXMO_LOCK_SUSPEND" = "1" ]; then
|
if [ "$SXMO_LOCK_SUSPEND" = "1" ]; then
|
||||||
crust
|
sxmo_screenlock.sh crust
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +38,7 @@ typeenter() {
|
||||||
if [ "$(sxmo_screenlock.sh getCurState)" != "unlock" ]; then
|
if [ "$(sxmo_screenlock.sh getCurState)" != "unlock" ]; then
|
||||||
case "$ACTION" in
|
case "$ACTION" in
|
||||||
"volup_three")
|
"volup_three")
|
||||||
crust
|
sxmo_screenlock.sh crust
|
||||||
;;
|
;;
|
||||||
"voldown_three")
|
"voldown_three")
|
||||||
if [ "$(sxmo_screenlock.sh getCurState)" = "lock" ]; then
|
if [ "$(sxmo_screenlock.sh getCurState)" = "lock" ]; then
|
||||||
|
|
41
scripts/core/sxmo_rtcwake.sh
Executable file → Normal file
41
scripts/core/sxmo_rtcwake.sh
Executable file → Normal file
|
@ -1,11 +1,40 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
# This script (and anything it calls) should return as quickly as possible
|
# shellcheck disable=SC1090
|
||||||
# as it blocks the system from suspending (and processing input) until done
|
. "$(which sxmo_common.sh)"
|
||||||
|
|
||||||
# If this script returns a non-zero exit code, the system will wake up
|
REDLED_PATH="/sys/class/leds/red:indicator/brightness"
|
||||||
|
BLUELED_PATH="/sys/class/leds/blue:indicator/brightness"
|
||||||
|
|
||||||
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/rtcwake" ]; then
|
finish() {
|
||||||
"$XDG_CONFIG_HOME/sxmo/hooks/rtcwake"
|
kill $BLINKPID
|
||||||
exit $?
|
|
||||||
|
sxmo_screenlock.sh updateLed
|
||||||
|
|
||||||
|
if grep -q rtc "$UNSUSPENDREASONFILE"; then
|
||||||
|
# Going back to crust
|
||||||
|
if [ "$(sxmo_screenlock.sh getCurState)" != "unlock" ]; then
|
||||||
|
sxmo_screenlock.sh crust
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
trap 'finish' TERM INT EXIT
|
||||||
|
|
||||||
|
blink() {
|
||||||
|
while [ "$(sxmo_screenlock.sh getCurState)" != "unlock" ]; do
|
||||||
|
echo 1 > "$REDLED_PATH"
|
||||||
|
echo 0 > "$BLUELED_PATH"
|
||||||
|
sleep 0.25
|
||||||
|
echo 0 > "$REDLED_PATH"
|
||||||
|
echo 1 > "$BLUELED_PATH"
|
||||||
|
sleep 0.25
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
blink &
|
||||||
|
BLINKPID=$!
|
||||||
|
|
||||||
|
"$@"
|
||||||
|
|
|
@ -100,6 +100,7 @@ elif [ "$1" = "unlock" ] ; then
|
||||||
xset dpms force on
|
xset dpms force on
|
||||||
xinput enable "$TOUCH_POINTER_ID"
|
xinput enable "$TOUCH_POINTER_ID"
|
||||||
sxmo_lisgdstart.sh
|
sxmo_lisgdstart.sh
|
||||||
|
echo 16000 > "$NETWORKRTCSCAN"
|
||||||
|
|
||||||
updateLed
|
updateLed
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -120,41 +121,6 @@ elif [ "$1" = "off" ] ; then
|
||||||
exit 0
|
exit 0
|
||||||
elif [ "$1" = "crust" ] ; then
|
elif [ "$1" = "crust" ] ; then
|
||||||
getCurState > "$LASTSTATE"
|
getCurState > "$LASTSTATE"
|
||||||
|
|
||||||
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/presuspend" ]; then
|
|
||||||
"$XDG_CONFIG_HOME/sxmo/hooks/presuspend"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo 1 > "$REDLED_PATH"
|
|
||||||
echo 0 > "$BLUELED_PATH"
|
|
||||||
xset dpms force off
|
|
||||||
|
|
||||||
# configure crust
|
|
||||||
# TODO: disable all wakeup sources other than button, rtc, and modem.
|
|
||||||
# TODO: make sure there is logic in whichWake and saveAllEventCounts functions
|
|
||||||
# Do I need to unbind? https://git.sr.ht/~mil/sxmo-utils/commit/bcf4f5c24968df0055d15a9fca649f67de9ced6a
|
|
||||||
echo "deep" > /sys/power/mem_sleep # deep sleep
|
|
||||||
|
|
||||||
echo "mem" > /sys/power/state
|
|
||||||
|
|
||||||
echo "crust" > "$LASTSTATE"
|
|
||||||
|
|
||||||
d=$(date)
|
|
||||||
echo "sxmo_screenlock: woke up from crust ($d)" >&2
|
|
||||||
|
|
||||||
updateLed
|
|
||||||
xset dpms force on
|
|
||||||
|
|
||||||
UNSUSPENDREASON=$(whichWake)
|
|
||||||
echo "$UNSUSPENDREASON" > "$UNSUSPENDREASONFILE"
|
|
||||||
|
|
||||||
if [ "$UNSUSPENDREASON" = "button" ] && [ -x "$XDG_CONFIG_HOME/sxmo/hooks/postwake" ]; then
|
|
||||||
"$XDG_CONFIG_HOME/sxmo/hooks/postwake"
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
elif [ "$1" = "rtc" ] ; then
|
|
||||||
getCurState > "$LASTSTATE"
|
|
||||||
# USER MUST USE sxmo_screenlock.sh rtc rather than using rtcwake directly.
|
# USER MUST USE sxmo_screenlock.sh rtc rather than using rtcwake directly.
|
||||||
# With this new version of lock, we dont check the exit code of the user hook. User must execute "sxmo_screenlock.sh rtc $TIME" at the end of their hook (depending on whether they want to re-rtc)
|
# With this new version of lock, we dont check the exit code of the user hook. User must execute "sxmo_screenlock.sh rtc $TIME" at the end of their hook (depending on whether they want to re-rtc)
|
||||||
echo 1 > "$REDLED_PATH"
|
echo 1 > "$REDLED_PATH"
|
||||||
|
@ -167,20 +133,19 @@ elif [ "$1" = "rtc" ] ; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
xset dpms force off
|
xset dpms force off
|
||||||
rtcwake -m mem -s "$2"
|
suspend_time="$(($(mnc)-10))"
|
||||||
|
if [ "$suspend_time" -gt 0 ]; then
|
||||||
|
rtcwake -m mem -s "$suspend_time"
|
||||||
UNSUSPENDREASON=$(whichWake)
|
UNSUSPENDREASON=$(whichWake)
|
||||||
|
else
|
||||||
|
UNSUSPENDREASON=rtc # we fake the crust for those seconds
|
||||||
|
fi
|
||||||
echo "$UNSUSPENDREASON" > "$UNSUSPENDREASONFILE"
|
echo "$UNSUSPENDREASON" > "$UNSUSPENDREASONFILE"
|
||||||
|
|
||||||
echo "crust" > "$LASTSTATE"
|
echo "crust" > "$LASTSTATE"
|
||||||
|
|
||||||
updateLed
|
updateLed
|
||||||
|
|
||||||
if [ "$UNSUSPENDREASON" = "rtc" ]; then
|
|
||||||
WAKEHOOK="$XDG_CONFIG_HOME/sxmo/hooks/rtcwake";
|
|
||||||
elif [ "$UNSUSPENDREASON" = "button" ]; then
|
|
||||||
WAKEHOOK="$XDG_CONFIG_HOME/sxmo/hooks/postwake";
|
|
||||||
fi
|
|
||||||
|
|
||||||
d=$(date)
|
d=$(date)
|
||||||
echo "sxmo_screenlock: woke up from crust (reason=$UNSUSPENDREASON) ($d)" >&2
|
echo "sxmo_screenlock: woke up from crust (reason=$UNSUSPENDREASON) ($d)" >&2
|
||||||
|
|
||||||
|
@ -188,16 +153,18 @@ elif [ "$1" = "rtc" ] ; then
|
||||||
xset dpms force on
|
xset dpms force on
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -x "$WAKEHOOK" ]; then
|
if [ "$UNSUSPENDREASON" = "button" ] && [ -x "$XDG_CONFIG_HOME/sxmo/hooks/postwake" ]; then
|
||||||
echo 1200 > "$NETWORKRTCSCAN"
|
echo 1200 > "$NETWORKRTCSCAN"
|
||||||
"$WAKEHOOK"
|
"$XDG_CONFIG_HOME/sxmo/hooks/postwake"
|
||||||
echo 16000 > "$NETWORKRTCSCAN"
|
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
elif [ "$1" = "getCurState" ] ; then
|
elif [ "$1" = "getCurState" ] ; then
|
||||||
getCurState
|
getCurState
|
||||||
exit 0
|
exit 0
|
||||||
|
elif [ "$1" = "updateLed" ] ; then
|
||||||
|
updateLed
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo "usage: sxmo_screenlock.sh [lock|unlock|off|crust|rtc|getCurState]">&2
|
echo "usage: sxmo_screenlock.sh [lock|unlock|off|crust|rtc|getCurState|updateLed]">&2
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue