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>
This commit is contained in:
Stacy Harper 2021-06-29 19:21:00 +02:00 committed by Maarten van Gompel
parent 0ed27f8538
commit e6ea657634
22 changed files with 160 additions and 254 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 &

View file

@ -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

View file

@ -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

View file

@ -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
}

View file

@ -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

View file

@ -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() {