sxmo-utils/configs/default_hooks/postwake
Stacy Harper dbca3ddd80
Trigger postwake when leaving crust cause of USB-C power
Atm, only the button wake up reason was trigerring postwake. This make
the usb charger to uncrust the phone and leave it in lock or off mode.

Now postwake take an argument which is the wake up reason.

The modem reason should not manage so phone state so we make it explicit
in the default hook.

"usb power" and "button" now make the phone to blink 5 seconds and put
the phone back to crust.
2021-07-07 21:00:42 +02:00

45 lines
831 B
Bash

#!/usr/bin/env sh
. "$(which sxmo_common.sh)"
if [ "$1" = "modem" ]; then
# Modem wakeup will be handled by the modemmonitor loops
# We should not manage the phone lock state here
exit 0
fi
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 crust
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=$!
# Replace this by wathever you want to do
sleep 5