Move LED setting to be indpendent of notification hook
This commit is contained in:
parent
46acb72dd7
commit
68641aab4f
1 changed files with 21 additions and 18 deletions
|
@ -1,7 +1,6 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
trap gracefulexit INT TERM
|
trap gracefulexit INT TERM
|
||||||
NOTIFDIR="$XDG_CONFIG_HOME"/sxmo/notifications
|
NOTIFDIR="$XDG_CONFIG_HOME"/sxmo/notifications
|
||||||
NOTIFHOOKPIDS=""
|
|
||||||
|
|
||||||
gracefulexit() {
|
gracefulexit() {
|
||||||
echo "Gracefully exiting $0"
|
echo "Gracefully exiting $0"
|
||||||
|
@ -15,11 +14,8 @@ notificationhook() {
|
||||||
VIBS=5
|
VIBS=5
|
||||||
VIBI=0
|
VIBI=0
|
||||||
while [ $VIBI -lt $VIBS ]; do
|
while [ $VIBI -lt $VIBS ]; do
|
||||||
sxmo_setpineled green 0
|
|
||||||
sleep 0.1
|
|
||||||
sxmo_vibratepine 400 &
|
sxmo_vibratepine 400 &
|
||||||
sxmo_setpineled green 1
|
sleep 0.5
|
||||||
sleep 0.4
|
|
||||||
VIBI=$(echo $VIBI+1 | bc)
|
VIBI=$(echo $VIBI+1 | bc)
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
@ -33,17 +29,20 @@ handlenewnotiffile(){
|
||||||
rm -f "$NOTIFFILE"
|
rm -f "$NOTIFFILE"
|
||||||
else
|
else
|
||||||
notificationhook &
|
notificationhook &
|
||||||
NOTIFHOOKPIDS="$NOTIFHOOKPIDS $!"
|
|
||||||
NOTIFACTION="$(awk NR==1 "$NOTIFFILE")"
|
NOTIFACTION="$(awk NR==1 "$NOTIFFILE")"
|
||||||
NOTIFWATCHFILE="$(awk NR==2 "$NOTIFFILE")"
|
NOTIFWATCHFILE="$(awk NR==2 "$NOTIFFILE")"
|
||||||
NOTIFMSG="$(tail -n+3 "$NOTIFFILE" | cut -c1-70)"
|
NOTIFMSG="$(tail -n+3 "$NOTIFFILE" | cut -c1-70)"
|
||||||
|
|
||||||
if dunstify --action="2,open" "$NOTIFMSG" | grep 2; then
|
(
|
||||||
|
dunstify --action="2,open" "$NOTIFMSG" | grep 2 && (
|
||||||
setsid -f sh -c "$NOTIFACTION" &
|
setsid -f sh -c "$NOTIFACTION" &
|
||||||
rm -f "$NOTIFFILE"
|
rm -f "$NOTIFFILE"
|
||||||
elif [ -e "$NOTIFWATCHFILE" ]; then
|
)
|
||||||
(inotifywait "$NOTIFWATCHFILE" && rm -f "$NOTIFFILE") &
|
) &
|
||||||
fi
|
|
||||||
|
[ -e "$NOTIFWATCHFILE" ] && (
|
||||||
|
inotifywait "$NOTIFWATCHFILE" && rm -f "$NOTIFFILE"
|
||||||
|
) &
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,17 +53,20 @@ recreateexistingnotifs() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
syncled() {
|
||||||
|
sxmo_setpineled green 0
|
||||||
|
if [ "$(find "$NOTIFDIR"/ -type f | wc -l)" -gt 0 ]; then
|
||||||
|
sleep 0.1
|
||||||
|
sxmo_setpineled green 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
monitorforaddordelnotifs() {
|
monitorforaddordelnotifs() {
|
||||||
while true; do
|
while true; do
|
||||||
if [ "$(find "$NOTIFDIR"/ -type f | wc -l)" -lt 1 ]; then
|
|
||||||
sxmo_setpineled green 0
|
|
||||||
echo "$NOTIFHOOKPIDS" | tr ' ' '\n' | xargs -IP kill -9 P
|
|
||||||
NOTIFHOOKPIDS=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
inotifywait -e create,attrib,moved_to,delete,delete_self,moved_from "$NOTIFDIR"/ | (
|
inotifywait -e create,attrib,moved_to,delete,delete_self,moved_from "$NOTIFDIR"/ | (
|
||||||
INOTIFYOUTPUT="$(cat)"
|
INOTIFYOUTPUT="$(cat)"
|
||||||
INOTIFYEVENTTYPE="$(echo "$INOTIFYOUTPUT" | cut -d" " -f2)"
|
INOTIFYEVENTTYPE="$(echo "$INOTIFYOUTPUT" | cut -d" " -f2)"
|
||||||
|
syncled
|
||||||
if echo "$INOTIFYEVENTTYPE" | grep -E "CREATE|MOVED_TO|ATTRIB"; then
|
if echo "$INOTIFYEVENTTYPE" | grep -E "CREATE|MOVED_TO|ATTRIB"; then
|
||||||
NOTIFFILE="$NOTIFDIR/$(echo "$INOTIFYOUTPUT" | cut -d" " -f3)"
|
NOTIFFILE="$NOTIFDIR/$(echo "$INOTIFYOUTPUT" | cut -d" " -f3)"
|
||||||
handlenewnotiffile "$NOTIFFILE"
|
handlenewnotiffile "$NOTIFFILE"
|
||||||
|
@ -76,4 +78,5 @@ monitorforaddordelnotifs() {
|
||||||
pgrep -f "$(command -v sxmo_notificationmonitor.sh)" | grep -Ev "^${$}$" | xargs kill
|
pgrep -f "$(command -v sxmo_notificationmonitor.sh)" | grep -Ev "^${$}$" | xargs kill
|
||||||
rm -f "$NOTIFDIR"/incomingcall
|
rm -f "$NOTIFDIR"/incomingcall
|
||||||
recreateexistingnotifs
|
recreateexistingnotifs
|
||||||
|
syncled
|
||||||
monitorforaddordelnotifs
|
monitorforaddordelnotifs
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue