Add proximity lock toggle on the config menu

Signed-off-by: Stacy Harper <contact@stacyharper.net>
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
master
Stacy Harper 4 years ago committed by Maarten van Gompel
parent f4ee396394
commit 6426a94e46
  1. 4
      scripts/core/sxmo_appmenu.sh
  2. 13
      scripts/core/sxmo_proximitylock.sh
  3. 18
      scripts/core/sxmo_proximitylocktoggle.sh
  4. 5
      scripts/modem/sxmo_modemcall.sh

@ -136,6 +136,10 @@ programchoicesinit() {
pgrep -f "$(command -v sxmo_rotateautotoggle.sh)" > /dev/null &&
printf %b "On → Off ^ 0 ^ sxmo_rotateautotoggle.sh &" || printf %b "Off → On ^ 0 ^ sxmo_rotateautotoggle.sh &"
)
$icon_lck Proximity Lock $(
pgrep -f "$(command -v sxmo_proximitylock.sh)" > /dev/null &&
printf %b "On → Off ^ 0 ^ sxmo_proximitylocktoggle.sh &" || printf %b "Off → On ^ 0 ^ sxmo_proximitylocktoggle.sh &"
)
$icon_ror Rotate ^ 1 ^ sxmo_rotate.sh rotate
$icon_upc Upgrade Pkgs ^ 0 ^ st -e sxmo_upgrade.sh
$icon_cfg Edit configuration ^ 0 ^ st -e $EDITOR $XDG_CONFIG_HOME/sxmo/xinit

@ -1,7 +1,16 @@
#!/usr/bin/env sh
islocked() {
pgrep -f sxmo_lock.sh > /dev/null
}
syncstate() {
islocked && STATE=locked || STATE=free
}
finish() {
kill $(jobs -p)
syncstate
[ free = "$STATE" ] && [ true = "$WASLOCKED" ] && sxmo_lock.sh &
exit 0
}
@ -18,10 +27,12 @@ TARGET=30
mainloop() {
while true; do
distance="$(distance)"
# here we do not syncstate to allow user manual lock
if [ locked = "$STATE" ] && [ "$distance" -lt "$TARGET" ]; then
pkill -f sxmo_lock.sh
STATE=free
elif [ free = "$STATE" ] && [ "$distance" -gt "$TARGET" ]; then
islocked && pkill -f sxmo_lock.sh # we want screen-off on proximity
sxmo_lock.sh --screen-off &
STATE=locked
fi
@ -29,7 +40,7 @@ mainloop() {
done
}
pgrep -f sxmo_lock.sh > /dev/null && STATE=locked || STATE=free
syncstate
if [ locked = "$STATE" ]; then
WASLOCKED=true

@ -0,0 +1,18 @@
#!/usr/bin/env sh
proximitylockdisable() {
notify-send "Proximity Lock Disabled"
pkill -f "$(command -v sxmo_proximitylock.sh)"
exit 0
}
proximitylockenable() {
notify-send "Proximity Lock Enabled"
setsid -f sxmo_proximitylock.sh &
}
if pgrep -f "$(command -v sxmo_proximitylock.sh)"; then
proximitylockdisable
else
proximitylockenable
fi

@ -25,7 +25,7 @@ finish() {
echo "sxmo_modemcall: $1">&2
notify-send "$1"
fi
kill $LOCKPID
[ -n "$LOCKPID" ] && kill $LOCKPID
pkill -9 dmenu
exit 1
}
@ -257,8 +257,11 @@ incomingcallmenu() {
modem_n || finish "Couldn't determine modem number - is modem online?"
# do not duplicate proximity lock if already running
if ! pgrep -f sxmo_proximitylock.sh > /dev/null; then
sxmo_proximitylock.sh &
LOCKPID="$!"
fi
"$@" &
MAINPID="$!"

Loading…
Cancel
Save