Cleanup hooks

This add a script to use either the user hook or the default one.

Sometime we checked the user hook or a default code. We move this
default code in a defaut hook.

Signed-off-by: Stacy Harper <contact@stacyharper.net>
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
master
Stacy Harper 3 years ago committed by Maarten van Gompel
parent 0ed27f8538
commit e6ea657634
  1. 1
      Makefile
  2. 55
      configs/default_hooks/lisgdstart
  3. 3
      configs/default_hooks/lock
  4. 9
      configs/default_hooks/notification
  5. 11
      configs/default_hooks/presuspend
  6. 4
      configs/default_hooks/unlock
  7. 37
      configs/default_hooks/unlocksim
  8. 4
      scripts/core/sxmo_common.sh
  9. 10
      scripts/core/sxmo_hooks.sh
  10. 59
      scripts/core/sxmo_lisgdstart.sh
  11. 23
      scripts/core/sxmo_lock.sh
  12. 16
      scripts/core/sxmo_migrate.sh
  13. 12
      scripts/core/sxmo_networkmonitor.sh
  14. 16
      scripts/core/sxmo_postwake.sh
  15. 18
      scripts/core/sxmo_presuspend.sh
  16. 6
      scripts/core/sxmo_rotate.sh
  17. 22
      scripts/core/sxmo_screenlock.sh
  18. 11
      scripts/core/sxmo_xinit.sh
  19. 18
      scripts/modem/sxmo_modemcall.sh
  20. 22
      scripts/modem/sxmo_modemmonitor.sh
  21. 41
      scripts/modem/sxmo_unlocksim.sh
  22. 16
      scripts/notifications/sxmo_notificationmonitor.sh

@ -32,6 +32,7 @@ clean:
install: $(PROGRAMS)
cd configs && find . -type f -exec install -D -m 0644 "{}" "$(DESTDIR)$(PREFIX)/share/sxmo/{}" \; && cd ..
cd configs && find default_hooks -type f -exec install -D -m 0655 "{}" "$(DESTDIR)$(PREFIX)/share/sxmo/{}" \; && cd ..
cd resources && find . -type f -exec install -D -m 0644 "{}" "$(DESTDIR)$(PREFIX)/share/sxmo/{}" \; && cd ..

@ -0,0 +1,55 @@
#!/usr/bin/env sh
# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. "$(which sxmo_common.sh)"
pkill -9 lisgd
if [ -z "$LISGD_THRESHOLD" ]; then
LISGD_THRESHOLD=125
fi
if [ -z "$LISGD_THRESHOLD_PRESSED" ]; then
LISGD_THRESHOLD_PRESSED=60
fi
#-g format:
# fingers,swipe,edge,distance,command
#order matters, only the first match gets executed
lisgd "$@" -t "$LISGD_THRESHOLD" -T "$LISGD_THRESHOLD_PRESSED" \
-g '1,DRUL,BR,*,sxmo_inputhandler.sh bottomrightcorner' \
-g '1,DLUR,BL,*,sxmo_inputhandler.sh bottomleftcorner' \
-g '1,ULDR,TL,*,sxmo_inputhandler.sh topleftcorner' \
-g '1,URDL,TR,*,sxmo_inputhandler.sh toprightcorner' \
-g '1,LR,B,L,sxmo_inputhandler.sh rightbottomcorner' \
-g '1,RL,B,L,sxmo_inputhandler.sh leftbottomcorner' \
-g '1,LR,L,*,sxmo_inputhandler.sh rightleftcorner' \
-g '1,RL,R,*,sxmo_inputhandler.sh leftrightcorner' \
-g '1,DU,L,*,P,sxmo_inputhandler.sh upleftcorner' \
-g '1,UD,L,*,P,sxmo_inputhandler.sh downleftcorner' \
-g '1,LR,T,*,P,sxmo_inputhandler.sh righttopcorner' \
-g '1,RL,T,*,P,sxmo_inputhandler.sh lefttopcorner' \
-g "1,DU,B,*,sxmo_inputhandler.sh upbottomcorner" \
-g "1,UD,B,*,sxmo_inputhandler.sh downbottomcorner" \
-g "1,UD,T,*,sxmo_inputhandler.sh downtopcorner" \
-g "1,DU,T,*,sxmo_inputhandler.sh uptopcorner" \
-g "2,UD,T,*,sxmo_inputhandler.sh twodowntopcorner" \
-g "2,UD,B,*,sxmo_inputhandler.sh twodownbottomcorner" \
-g "r,UD,B,*,sxmo_inputhandler.sh threedownbottomcorner" \
-g '1,DU,R,*,P,sxmo_inputhandler.sh uprightcorner' \
-g '1,UD,R,*,P,sxmo_inputhandler.sh downrightcorner' \
-g '1,LR,R,S,sxmo_inputhandler.sh rightrightcorner_short' \
-g '1,RL,L,S,sxmo_inputhandler.sh leftrightcorner_short' \
-g '1,RL,*,*,sxmo_inputhandler.sh left' \
-g '1,LR,*,*,sxmo_inputhandler.sh right' \
-g '1,DU,*,*,sxmo_inputhandler.sh up' \
-g '1,UD,*,*,sxmo_inputhandler.sh down' \
-g '1,DRUL,*,*,sxmo_inputhandler.sh upleft' \
-g '1,URDL,*,*,sxmo_inputhandler.sh downleft' \
-g '1,DLUR,*,*,sxmo_inputhandler.sh upright' \
-g '1,ULDR,*,*,sxmo_inputhandler.sh downright' \
-g '2,RL,*,*,sxmo_inputhandler.sh twoleft' \
-g '2,LR,*,*,sxmo_inputhandler.sh tworight' \
-g '2,DU,*,*,sxmo_inputhandler.sh twoup' \
-g '2,UD,*,*,sxmo_inputhandler.sh twodown' \
>"$CACHEDIR/lisgd.log" 2>&1

@ -0,0 +1,3 @@
#!/usr/bin/env sh
pkill -9 lisgd

@ -0,0 +1,9 @@
#!/usr/bin/env sh
VIBS=5
VIBI=0
while [ $VIBI -lt $VIBS ]; do
sxmo_vibratepine 400 &
sleep 0.5
VIBI=$(echo $VIBI+1 | bc)
done

@ -0,0 +1,11 @@
#!/usr/bin/env sh
# This script is called prior to suspending
# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. "$(which sxmo_common.sh)"
pkill -STOP conky
pkill clickclack
pkill -f "$KEYBOARD"

@ -0,0 +1,4 @@
#!/usr/bin/env sh
[ "$(xrandr | grep DSI-1 | cut -d ' ' -f 5)" = "right" ] && ORIENTATION=1 || ORIENTATION=0
sxmo_hooks.sh lisgdstart -o $ORIENTATION &

@ -0,0 +1,37 @@
#!/usr/bin/env sh
# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. "$(dirname "$0")/sxmo_common.sh"
modem_n() {
MODEMS="$(mmcli -L)"
echo "$MODEMS" | grep -oE 'Modem\/([0-9]+)' | cut -d'/' -f2
return
}
sim_n() {
SIMS="$(mmcli -m "$(modem_n)" | grep SIM)"
echo "$SIMS" | grep -oE 'SIM\/([0-9]+)' | cut -d'/' -f2
return
}
retry=1
pkill dmenu #kill existing dmenu
while [ $retry -eq 1 ]; do
PICKED="$(
# shellcheck disable=SC2039,SC3037
echo -e "Cancel\n0000\n1234" | sxmo_dmenu_with_kb.sh -l 3 -c -p "PIN:" | tr -d "\n\r "
)"
if [ -n "$PICKED" ] && [ "$PICKED" != "Cancel" ]; then
retry=0
mmcli -i "$(sim_n)" --pin "$PICKED" > /tmp/unlockmsg 2>&1 || retry=1
MSG=$(cat /tmp/unlockmsg)
[ -n "$MSG" ] && notify-send "$MSG"
if echo "$MSG" | grep -q "not SIM-PIN locked"; then
retry=0
fi
else
retry=0
fi
done

@ -255,6 +255,4 @@ icon_bok=""
icon_map=""
#allow the user to override icons
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/icons" ]; then
"$XDG_CONFIG_HOME/sxmo/hooks/icons"
fi
sxmo_hooks.sh icons

@ -0,0 +1,10 @@
#!/usr/bin/env sh
hook="$1"
shift
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/$hook" ]; then
exec "$XDG_CONFIG_HOME/sxmo/hooks/$hook" "$@"
elif [ -x "/usr/share/sxmo/default_hooks/$hook" ]; then
exec "/usr/share/sxmo/default_hooks/$hook" "$@"
fi

@ -1,59 +0,0 @@
#!/usr/bin/env sh
# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. "$(dirname "$0")/sxmo_common.sh"
pkill -9 lisgd
if [ -z "$LISGD_THRESHOLD" ]; then
LISGD_THRESHOLD=125
fi
if [ -z "$LISGD_THRESHOLD_PRESSED" ]; then
LISGD_THRESHOLD_PRESSED=60
fi
if [ -x "$XDG_CONFIG_HOME"/sxmo/hooks/lisgdstart ]; then
"$XDG_CONFIG_HOME"/sxmo/hooks/lisgdstart "$@" &
else
#-g format:
# fingers,swipe,edge,distance,command
#order matters, only the first match gets executed
lisgd "$@" -t "$LISGD_THRESHOLD" -T "$LISGD_THRESHOLD_PRESSED" \
-g '1,DRUL,BR,*,sxmo_inputhandler.sh bottomrightcorner' \
-g '1,DLUR,BL,*,sxmo_inputhandler.sh bottomleftcorner' \
-g '1,ULDR,TL,*,sxmo_inputhandler.sh topleftcorner' \
-g '1,URDL,TR,*,sxmo_inputhandler.sh toprightcorner' \
-g '1,LR,B,L,sxmo_inputhandler.sh rightbottomcorner' \
-g '1,RL,B,L,sxmo_inputhandler.sh leftbottomcorner' \
-g '1,LR,L,*,sxmo_inputhandler.sh rightleftcorner' \
-g '1,RL,R,*,sxmo_inputhandler.sh leftrightcorner' \
-g '1,DU,L,*,P,sxmo_inputhandler.sh upleftcorner' \
-g '1,UD,L,*,P,sxmo_inputhandler.sh downleftcorner' \
-g '1,LR,T,*,P,sxmo_inputhandler.sh righttopcorner' \
-g '1,RL,T,*,P,sxmo_inputhandler.sh lefttopcorner' \
-g "1,DU,B,*,sxmo_inputhandler.sh upbottomcorner" \
-g "1,UD,B,*,sxmo_inputhandler.sh downbottomcorner" \
-g "1,UD,T,*,sxmo_inputhandler.sh downtopcorner" \
-g "1,DU,T,*,sxmo_inputhandler.sh uptopcorner" \
-g "2,UD,T,*,sxmo_inputhandler.sh twodowntopcorner" \
-g "2,UD,B,*,sxmo_inputhandler.sh twodownbottomcorner" \
-g "r,UD,B,*,sxmo_inputhandler.sh threedownbottomcorner" \
-g '1,DU,R,*,P,sxmo_inputhandler.sh uprightcorner' \
-g '1,UD,R,*,P,sxmo_inputhandler.sh downrightcorner' \
-g '1,LR,R,S,sxmo_inputhandler.sh rightrightcorner_short' \
-g '1,RL,L,S,sxmo_inputhandler.sh leftrightcorner_short' \
-g '1,RL,*,*,sxmo_inputhandler.sh left' \
-g '1,LR,*,*,sxmo_inputhandler.sh right' \
-g '1,DU,*,*,sxmo_inputhandler.sh up' \
-g '1,UD,*,*,sxmo_inputhandler.sh down' \
-g '1,DRUL,*,*,sxmo_inputhandler.sh upleft' \
-g '1,URDL,*,*,sxmo_inputhandler.sh downleft' \
-g '1,DLUR,*,*,sxmo_inputhandler.sh upright' \
-g '1,ULDR,*,*,sxmo_inputhandler.sh downright' \
-g '2,RL,*,*,sxmo_inputhandler.sh twoleft' \
-g '2,LR,*,*,sxmo_inputhandler.sh tworight' \
-g '2,DU,*,*,sxmo_inputhandler.sh twoup' \
-g '2,UD,*,*,sxmo_inputhandler.sh twodown' \
>"$CACHEDIR/lisgd.log" 2>&1 &
fi

@ -1,23 +0,0 @@
#!/usr/bin/env sh
# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. "$(dirname "$0")/sxmo_common.sh"
finish() {
kill "$LOCKPID"
}
trap 'finish' TERM INT
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/lock" ]; then
"$XDG_CONFIG_HOME/sxmo/hooks/lock"
fi
pkill -9 lisgd
sxmo_screenlock "$@" &
LOCKPID="$!"
wait $LOCKPID
[ "$(xrandr | grep DSI-1 | cut -d ' ' -f 5)" = "right" ] && ORIENTATION=1 || ORIENTATION=0
sxmo_lisgdstart.sh -o $ORIENTATION &
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/unlock" ]; then
"$XDG_CONFIG_HOME/sxmo/hooks/unlock"
fi

@ -28,18 +28,4 @@ defaultconfig() {
fi
}
defaultconfigs() {
defaultconfig /usr/share/sxmo/appcfg/xinit_template "$XDG_CONFIG_HOME/sxmo/xinit" 744
defaultconfig /usr/share/sxmo/default_hooks/discard "$XDG_CONFIG_HOME/sxmo/hooks/discard" 744
defaultconfig /usr/share/sxmo/default_hooks/missed_call "$XDG_CONFIG_HOME/sxmo/hooks/missed_call" 744
defaultconfig /usr/share/sxmo/default_hooks/mute_ring "$XDG_CONFIG_HOME/sxmo/hooks/mute_ring" 744
defaultconfig /usr/share/sxmo/default_hooks/pickup "$XDG_CONFIG_HOME/sxmo/hooks/pickup" 744
defaultconfig /usr/share/sxmo/default_hooks/postwake "$XDG_CONFIG_HOME/sxmo/hooks/postwake" 744
defaultconfig /usr/share/sxmo/default_hooks/ring "$XDG_CONFIG_HOME/sxmo/hooks/ring" 744
defaultconfig /usr/share/sxmo/default_hooks/rtcwake "$XDG_CONFIG_HOME/sxmo/hooks/rtcwake" 744
defaultconfig /usr/share/sxmo/default_hooks/sms "$XDG_CONFIG_HOME/sxmo/hooks/sms" 744
defaultconfig /usr/share/sxmo/default_hooks/battery "$XDG_CONFIG_HOME/sxmo/hooks/battery" 744
defaultconfig /usr/share/sxmo/default_hooks/battery_crit "$XDG_CONFIG_HOME/sxmo/hooks/battery_crit" 744
}
defaultconfigs
defaultconfig /usr/share/sxmo/appcfg/xinit_template "$XDG_CONFIG_HOME/sxmo/xinit" 744

@ -21,22 +21,16 @@ dbus-monitor --system "interface='org.freedesktop.NetworkManager',type='signal',
if echo "$newstate" | grep "int32 70"; then
#network just connected (70=NM_STATE_CONNECTED_GLOBAL)
echo "network up">&2
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/network-up" ]; then
"$XDG_CONFIG_HOME/sxmo/hooks/network-up" &
fi
sxmo_hooks.sh network-up &
sxmo_statusbarupdate.sh
elif echo "$newstate" | grep "int32 20"; then
#network just disconnected (20=NM_STATE_DISCONNECTED)
echo "network down">&2
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/network-down" ]; then
"$XDG_CONFIG_HOME/sxmo/hooks/network-down" &
fi
sxmo_hooks.sh network-down &
sxmo_statusbarupdate.sh
elif echo "$newstate" | grep "int32 30"; then
#network is going down (30=NM_STATE_DISCONNECTING)
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/network-pre-down" ]; then
"$XDG_CONFIG_HOME/sxmo/hooks/network-pre-down" &
fi
sxmo_hooks.sh network-pre-down &
fi
fi
done &

@ -1,16 +0,0 @@
#!/usr/bin/env sh
# This script is called when the system has successfully woken up after sleep
# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. "$(dirname "$0")/sxmo_common.sh"
sxmo_statusbarupdate.sh
pkill -CONT conky
(sleep 15 && sxmo_resetscaninterval.sh) &
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/postwake" ]; then
"$XDG_CONFIG_HOME/sxmo/hooks/postwake"
fi

@ -1,18 +0,0 @@
#!/usr/bin/env sh
# This script is called prior to suspending
# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. "$(dirname "$0")/sxmo_common.sh"
pkill -STOP conky
pkill clickclack
pkill -f "$KEYBOARD"
# If this script returns a non-zero exit code, suspension will be cancelled
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/presuspend" ]; then
"$XDG_CONFIG_HOME/sxmo/hooks/presuspend"
exit $?
fi

@ -19,7 +19,7 @@ rotnormal() {
sxmo_keyboard.sh close
xrandr -o normal
applyptrmatrix 0 0 0 0 0 0 0 0 0
pidof lisgd && pkill lisgd | sxmo_lisgdstart.sh -o 0 &
pidof lisgd && pkill lisgd | sxmo_hooks.sh lisgdstart -o 0 &
exit 0
}
@ -27,7 +27,7 @@ rotright() {
sxmo_keyboard.sh close
xrandr -o right
applyptrmatrix 0 1 0 -1 0 1 0 0 1
pidof lisgd && pkill lisgd | sxmo_lisgdstart.sh -o 1 &
pidof lisgd && pkill lisgd | sxmo_hooks.sh lisgdstart -o 1 &
exit 0
}
@ -35,7 +35,7 @@ rotleft() {
sxmo_keyboard.sh close
xrandr -o left
applyptrmatrix 0 -1 1 1 0 0 0 0 1
pidof lisgd && pkill lisgd | sxmo_lisgdstart.sh -o 3 &
pidof lisgd && pkill lisgd | sxmo_hooks.sh lisgdstart -o 3 &
exit 0
}

@ -73,9 +73,7 @@ if [ "$1" = "lock" ] ; then
# TODO: Document LASTSTATE
getCurState > "$LASTSTATE"
# Do we want this hook after disabling all the input devices so users can enable certain devices?
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/lock" ]; then
"$XDG_CONFIG_HOME/sxmo/hooks/lock"
fi
sxmo_hooks.sh lock
xset dpms 0 0 0
xset dpms force on
@ -92,14 +90,12 @@ if [ "$1" = "lock" ] ; then
exit 0
elif [ "$1" = "unlock" ] ; then
getCurState > "$LASTSTATE"
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/unlock" ]; then
"$XDG_CONFIG_HOME/sxmo/hooks/unlock"
fi
sxmo_hooks.sh unlock
xset dpms 0 0 0
xset dpms force on
xinput enable "$TOUCH_POINTER_ID"
sxmo_lisgdstart.sh
sxmo_hooks.sh lisgdstart &
echo 16000 > "$NETWORKRTCSCAN"
updateLed
@ -107,9 +103,7 @@ elif [ "$1" = "unlock" ] ; then
elif [ "$1" = "off" ] ; then
getCurState > "$LASTSTATE"
# TODO: document this hook
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/screenoff" ]; then
"$XDG_CONFIG_HOME/sxmo/hooks/screenoff"
fi
sxmo_hooks.sh screenoff
xset dpms 0 0 3
xset dpms force off
@ -128,9 +122,7 @@ elif [ "$1" = "crust" ] ; then
saveAllEventCounts
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/presuspend" ]; then
"$XDG_CONFIG_HOME/sxmo/hooks/presuspend"
fi
sxmo_hooks.sh presuspend
xset dpms force off
suspend_time="$(($(mnc)-10))"
@ -153,9 +145,9 @@ elif [ "$1" = "crust" ] ; then
xset dpms force on
fi
if [ "$UNSUSPENDREASON" = "button" ] && [ -x "$XDG_CONFIG_HOME/sxmo/hooks/postwake" ]; then
if [ "$UNSUSPENDREASON" = "button" ]; then
echo 1200 > "$NETWORKRTCSCAN"
"$XDG_CONFIG_HOME/sxmo/hooks/postwake"
sxmo_hooks.sh postwake
fi
exit 0
elif [ "$1" = "getCurState" ] ; then

@ -70,7 +70,7 @@ daemonsneedingdbus() {
dunst -conf /usr/share/sxmo/appcfg/dunst.conf &
sxmo_notificationmonitor.sh &
sxmo_networkmonitor.sh &
sxmo_lisgdstart.sh &
sxmo_hooks.sh lisgdstart &
}
defaultconfig() {
@ -85,15 +85,6 @@ defaultconfigs() {
[ -r "$XDG_CONFIG_HOME/sxmo/xinit" ] && return
defaultconfig /usr/share/sxmo/appcfg/xinit_template "$XDG_CONFIG_HOME/sxmo/xinit" 744
defaultconfig /usr/share/sxmo/default_hooks/discard "$XDG_CONFIG_HOME/sxmo/hooks/discard" 744
defaultconfig /usr/share/sxmo/default_hooks/missed_call "$XDG_CONFIG_HOME/sxmo/hooks/missed_call" 744
defaultconfig /usr/share/sxmo/default_hooks/mute_ring "$XDG_CONFIG_HOME/sxmo/hooks/mute_ring" 744
defaultconfig /usr/share/sxmo/default_hooks/pickup "$XDG_CONFIG_HOME/sxmo/hooks/pickup" 744
defaultconfig /usr/share/sxmo/default_hooks/postwake "$XDG_CONFIG_HOME/sxmo/hooks/postwake" 744
defaultconfig /usr/share/sxmo/default_hooks/ring "$XDG_CONFIG_HOME/sxmo/hooks/ring" 744
defaultconfig /usr/share/sxmo/default_hooks/rtcwake "$XDG_CONFIG_HOME/sxmo/hooks/rtcwake" 744
defaultconfig /usr/share/sxmo/default_hooks/sms "$XDG_CONFIG_HOME/sxmo/hooks/sms" 744
}
customxinit() {

@ -110,10 +110,8 @@ acceptcall() {
log_event "call_start" "$CALLID"
echo "sxmo_modemcall: Started call $CALLID">&2
elif [ "$DIRECTION" = "incoming" ]; then
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/pickup" ]; then
echo "sxmo_modemcall: Invoking pickup hook (async)">&2
"$XDG_CONFIG_HOME/sxmo/hooks/pickup" &
fi
echo "sxmo_modemcall: Invoking pickup hook (async)">&2
sxmo_hooks.sh pickup &
touch "$CACHEDIR/${CALLID}.pickedupcall" #this signals that we picked this call up
#to other asynchronously running processes
modem_cmd_errcheck -m "$(modem_n)" -o "$CALLID" --accept
@ -134,10 +132,8 @@ hangup() {
else
#this call was never picked up and hung up immediately, so it is a discarded call
touch "$CACHEDIR/${CALLID}.discardedcall" #this signals that we discarded this call to other asynchronously running processes
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/discard" ]; then
echo "sxmo_modemcall: Invoking discard hook (async)">&2
"$XDG_CONFIG_HOME/sxmo/hooks/discard" &
fi
echo "sxmo_modemcall: Invoking discard hook (async)">&2
sxmo_hooks.sh discard &
log_event "call_discard" "$CALLID"
fi
modem_cmd_errcheck -m "$(modem_n)" -o "$CALLID" --hangup
@ -228,10 +224,8 @@ pickup() {
mute() {
touch "$CACHEDIR/$1.mutedring" #this signals that we muted this ring
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/mute_ring" ]; then
echo "sxmo_modemmonitor: Invoking mute_ring hook (async)">&2
"$XDG_CONFIG_HOME/sxmo/hooks/mute_ring" "$CONTACTNAME" &
fi
echo "sxmo_modemmonitor: Invoking mute_ring hook (async)">&2
sxmo_hooks.sh mute_ring "$CONTACTNAME" &
log_event "ring_mute" "$1"
finish "Ringing with $NUMBER muted"
}

@ -125,10 +125,8 @@ checkforfinishedcalls() {
echo "sxmo_modemmonitor: Missed call from $FINISHEDNUMBER">&2
printf %b "$TIME\tcall_missed\t$FINISHEDNUMBER\n" >> "$LOGDIR/modemlog.tsv"
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/missed_call" ]; then
echo "sxmo_modemmonitor: Invoking missed call hook (async)">&2
"$XDG_CONFIG_HOME/sxmo/hooks/missed_call" "$CONTACTNAME" &
fi
echo "sxmo_modemmonitor: Invoking missed call hook (async)">&2
sxmo_hooks.sh missed_call "$CONTACTNAME" &
CONTACT="$(lookupcontactname "$FINISHEDNUMBER")"
sxmo_notificationwrite.sh \
@ -168,12 +166,8 @@ checkforincomingcalls() {
xset dpms force on
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/ring" ]; then
echo "sxmo_modemmonitor: Invoking ring hook (async)">&2
"$XDG_CONFIG_HOME/sxmo/hooks/ring" "$CONTACTNAME" &
else
sxmo_vibratepine 2500 &
fi
echo "sxmo_modemmonitor: Invoking ring hook (async)">&2
sxmo_hooks.sh ring "$CONTACTNAME" &
TIME="$(date --iso-8601=seconds)"
mkdir -p "$LOGDIR"
@ -224,9 +218,7 @@ checkfornewtexts() {
"$LOGDIR/$NUM/sms.txt" \
"Message - $CONTACTNAME: $TEXT"
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/sms" ]; then
"$XDG_CONFIG_HOME/sxmo/hooks/sms" "$CONTACTNAME" "$TEXT"
fi
sxmo_hooks.sh sms "$CONTACTNAME" "$TEXT"
done
if grep -q modem "$UNSUSPENDREASONFILE" && grep -q crust "$LASTSTATE"; then
@ -246,7 +238,7 @@ initialmodemstatus() {
echo registered > "$MODEMSTATEFILE"
elif echo "$state" | grep -q -E "^.*state:.*locked.*$"; then
echo locked > "$MODEMSTATEFILE"
pidof sxmo_unlocksim.sh || sxmo_unlocksim.sh &
pidof unlocksim || sxmo_hooks.sh unlocksim &
else
echo unknown > "$MODEMSTATEFILE"
fi
@ -290,7 +282,7 @@ mainloop() {
read -r newstate
if echo "$newstate" | grep "int32 2"; then
echo locked > "$MODEMSTATEFILE"
pidof sxmo_unlocksim.sh || sxmo_unlocksim.sh &
pidof unlocksim || sxmo_hooks.sh unlocksim &
elif echo "$newstate" | grep "int32 8"; then
echo registered > "$MODEMSTATEFILE"
checkforfinishedcalls

@ -1,41 +0,0 @@
#!/usr/bin/env sh
# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. "$(dirname "$0")/sxmo_common.sh"
modem_n() {
MODEMS="$(mmcli -L)"
echo "$MODEMS" | grep -oE 'Modem\/([0-9]+)' | cut -d'/' -f2
return
}
sim_n() {
SIMS="$(mmcli -m "$(modem_n)" | grep SIM)"
echo "$SIMS" | grep -oE 'SIM\/([0-9]+)' | cut -d'/' -f2
return
}
if [ -x "$XDG_CONFIG_HOME/sxmo/hooks/unlocksim" ]; then
"$XDG_CONFIG_HOME/sxmo/hooks/unlocksim" "$(sim_n)"
else
retry=1
pkill dmenu #kill existing dmenu
while [ $retry -eq 1 ]; do
PICKED="$(
# shellcheck disable=SC2039,SC3037
echo -e "Cancel\n0000\n1234" | sxmo_dmenu_with_kb.sh -l 3 -c -p "PIN:" | tr -d "\n\r "
)"
if [ -n "$PICKED" ] && [ "$PICKED" != "Cancel" ]; then
retry=0
mmcli -i "$(sim_n)" --pin "$PICKED" > /tmp/unlockmsg 2>&1 || retry=1
MSG=$(cat /tmp/unlockmsg)
[ -n "$MSG" ] && notify-send "$MSG"
if echo "$MSG" | grep -q "not SIM-PIN locked"; then
retry=0
fi
else
retry=0
fi
done
fi

@ -10,20 +10,6 @@ gracefulexit() {
kill -9 0
}
notificationhook() {
if [ -x "$XDG_CONFIG_HOME"/sxmo/hooks/notification ]; then
"$XDG_CONFIG_HOME"/sxmo/hooks/notification "$@"
else
VIBS=5
VIBI=0
while [ $VIBI -lt $VIBS ]; do
sxmo_vibratepine 400 &
sleep 0.5
VIBI=$(echo $VIBI+1 | bc)
done
fi
}
handlenewnotiffile(){
NOTIFFILE="$1"
@ -31,7 +17,7 @@ handlenewnotiffile(){
echo "Invalid notification file $NOTIFFILE found (<3 lines -- see notif spec in sxmo_notifwrite.sh), deleting!" >&2
rm -f "$NOTIFFILE"
else
notificationhook "$NOTIFFILE" &
sxmo_hooks.sh notification "$NOTIFFILE" &
NOTIFACTION="$(awk NR==1 "$NOTIFFILE")"
NOTIFWATCHFILE="$(awk NR==2 "$NOTIFFILE")"
NOTIFMSG="$(tail -n+3 "$NOTIFFILE" | cut -c1-70)"

Loading…
Cancel
Save