You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

36 lines
632 B

#!/usr/bin/env sh
isLocked() {
curState="$(sxmo_screenlock.sh getCurState)"
[ "$curState" = "lock" ] || [ "$curState" = "off" ]
}
finish() {
sxmo_screenlock.sh "$INITIALSTATE"
exit 0
}
trap 'finish' TERM INT
proximity_raw_bus="$(find /sys/ -name 'in_proximity_raw')"
distance() {
cat "$proximity_raw_bus"
}
TARGET=30
mainloop() {
while true; do
distance="$(distance)"
if isLocked && [ "$distance" -lt "$TARGET" ]; then
sxmo_screenlock.sh unlock
elif ! isLocked && [ "$distance" -gt "$TARGET" ]; then
sxmo_screenlock.sh off
fi
sleep 0.5
done
}
INITIALSTATE="$(sxmo_screenlock.sh getCurState)"
mainloop