If a notification body include a double whitespace, the PICKEDNOTIFFILE computation fail to match cause we striped them when building the dmenu choices. To give an example, try to write this notification as $ sxmo_notificationwrite.sh "random" \ "st -e tail -n9999 -f \"$HOME/.config/sxmo/xinit\"" \ "$HOME/.config/sxmo/xinit" \ "this body is broken" This patch fix this bug. (Maintainer note: I changed the awk invocation to use tr, as suggested by anjan) Signed-off-by: Reed Wade <reedwade@misterbanal.net> Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
33 lines
917 B
Bash
Executable file
33 lines
917 B
Bash
Executable file
#!/usr/bin/env sh
|
|
NOTIFDIR="$XDG_CONFIG_HOME"/sxmo/notifications
|
|
|
|
notificationmenu() {
|
|
CHOICES="Close Menu\nClear Notifications"
|
|
for NOTIFFILE in "$NOTIFDIR"/*; do
|
|
NOTIFMSG="$(tail -n+3 "$NOTIFFILE" | tr "\n^" " ")"
|
|
NOTIFHRANDMIN="$(stat --printf %y "$NOTIFFILE" | grep -oE '[0-9]{2}:[0-9]{2}')"
|
|
CHOICES="
|
|
$CHOICES
|
|
$NOTIFHRANDMIN - $NOTIFMSG ^ $NOTIFFILE
|
|
"
|
|
done
|
|
|
|
PICKEDCONTENT="$(
|
|
printf "%b" "$CHOICES" |
|
|
xargs -0 echo |
|
|
sed '/^[[:space:]]*$/d' |
|
|
awk '{$1=$1};1' |
|
|
cut -d^ -f1 |
|
|
dmenu -c -i -fn "Terminus-18" -p "Notifs" -l 10
|
|
)"
|
|
|
|
[ "$PICKEDCONTENT" = "Close Menu" ] && exit 1
|
|
[ "$PICKEDCONTENT" = "Clear Notifications" ] && rm "$NOTIFDIR"/* && exit 1
|
|
|
|
PICKEDNOTIFFILE="$(echo "$CHOICES" | awk '{$1=$1};1' | grep "$PICKEDCONTENT" | cut -d^ -f2 | tr -d ' ')"
|
|
NOTIFACTION="$(head -n1 "$PICKEDNOTIFFILE")"
|
|
setsid -f sh -c "$NOTIFACTION" &
|
|
rm "$PICKEDNOTIFFILE"
|
|
}
|
|
|
|
notificationmenu
|