parent
dcf5ddd77c
commit
e6635ba7ef
7 changed files with 103 additions and 17 deletions
@ -0,0 +1,48 @@ |
|||||||
|
#!/usr/bin/env sh |
||||||
|
|
||||||
|
# This script should be run to initialize the notification watchers. |
||||||
|
|
||||||
|
NOTIFDIR="$XDG_CONFIG_HOME"/sxmo/notifications |
||||||
|
|
||||||
|
handlecreation(){ |
||||||
|
sxmo_setpineled green 1; |
||||||
|
echo "$1" | grep "sxmo_incomingcall" || |
||||||
|
{ |
||||||
|
sxmo_vibratepine 200; |
||||||
|
sleep 0.1; |
||||||
|
sxmo_vibratepine 200; |
||||||
|
sleep 0.1; |
||||||
|
} & |
||||||
|
|
||||||
|
# Dunstify / start notification watcher if it matches the sxmo_notificationwrite format |
||||||
|
grep -c . "$1" | grep 3 && |
||||||
|
{ |
||||||
|
inotifywait "$(tail -1 "$1")" && rm -f "$1" & |
||||||
|
|
||||||
|
DUNST_RETURN="$(dunstify --action="2,open" "$(head -1 "$1" | cut -c1-70)")"; |
||||||
|
# shellcheck disable=SC2091 |
||||||
|
echo "$DUNST_RETURN" | grep -v 2 || { $(head -2 "$1" | tail -1)& } |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
sxmo_setpineled green 0 |
||||||
|
for NOTIF in "$NOTIFDIR"/*; do |
||||||
|
[ -f "$NOTIF" ] || continue |
||||||
|
handlecreation "$NOTIF" |
||||||
|
done |
||||||
|
|
||||||
|
while true; do |
||||||
|
{ |
||||||
|
DIREVENT="$(inotifywait -e create,moved_to,delete,delete_self,moved_from "$NOTIFDIR"/)" |
||||||
|
case "$(echo "$DIREVENT" | cut -d" " -f2)" in |
||||||
|
"CREATE"|"MOVED_TO") |
||||||
|
NOTIFFILE="$NOTIFDIR/$(echo "$DIREVENT" | cut -d" " -f3)" |
||||||
|
handlecreation "$NOTIFFILE" |
||||||
|
;; |
||||||
|
|
||||||
|
"DELETE"|"DELETE_SELF"|"MOVED_FROM") |
||||||
|
find "$NOTIFDIR"/ -type f -mindepth 1 | read -r || sxmo_setpineled green 0 |
||||||
|
;; |
||||||
|
esac |
||||||
|
} |
||||||
|
done |
@ -0,0 +1,16 @@ |
|||||||
|
#!/usr/bin/env sh |
||||||
|
|
||||||
|
NOTIFDIR="$XDG_CONFIG_HOME"/sxmo/notifications |
||||||
|
|
||||||
|
FILES="$(find "$NOTIFDIR"/ -type f -not -name 'sxmo_incomingcall')" |
||||||
|
for FILE in $FILES; do |
||||||
|
CHOICES="$(printf %b "$FILE\t$(echo "$FILE" | cut -d: -f4-6) $(head -1 "$FILE")\n$CHOICES")" |
||||||
|
done |
||||||
|
PICKED="$(printf %b "$CHOICES\nClose Menu" | cut -f2 | dmenu -c -i -fn "Terminus-18" -p "Notifs" -l 10)" |
||||||
|
|
||||||
|
echo "$PICKED" | grep "Close Menu" && exit 0 |
||||||
|
TIMESTAMP="$(echo "$PICKED" | cut -d" " -f1 | cut -d: -f4-6)" |
||||||
|
FILE="$(printf %b "$CHOICES" | grep "$PICKED" | cut -f1 | grep "$TIMESTAMP")" |
||||||
|
|
||||||
|
# shellcheck disable=SC2091 |
||||||
|
$(head -2 "$FILE" | tail -1) |
@ -0,0 +1,15 @@ |
|||||||
|
#!/usr/bin/env sh |
||||||
|
|
||||||
|
# This script takes 3 arguments, (1) a fuzzy description of the notification, (2) the action that the notification invokes upon selecting, and (3) the file to watch for deactivation. |
||||||
|
# A notification file has 3 different fields, (1) a fuzzy description, (2) the selection action, and (3) the watch file. |
||||||
|
|
||||||
|
NOTIFDIR="$XDG_CONFIG_HOME"/sxmo/notifications |
||||||
|
|
||||||
|
mkdir -p "$NOTIFDIR" |
||||||
|
echo "$3" | grep -v . && { echo "Not enough args."; exit 2; } |
||||||
|
|
||||||
|
# Don't send a notification if we're already looking at it! |
||||||
|
lsof | grep "$3" && exit 0 |
||||||
|
|
||||||
|
OUTFILE=$NOTIFDIR/$(date "+%Y:%m:%d:%H:%M:%S:%N") |
||||||
|
printf %b "$1\n$2\n$3\n" > "$OUTFILE" |
Loading…
Reference in new issue