Files
sxmo-utils/scripts/notifications/sxmo_notificationwrite.sh
Peter John Hartman aea5a73f51 notification: another fixup to devices without led
Oops, found a small bug where it didn't update statusbar if you clicked
on the message.  So this one should be good to go.

In re this:
377744c95b

There were two problems with that patch:

1. The check for SXMO_NO_LED never worked so every device was getting
   it.
2. The change to notificationwrite broke notificationwrite so no popups
were happening.

Signed-off-by: Stacy Harper <contact@stacyharper.net>
2022-11-07 20:01:33 +01:00

34 lines
981 B
Bash
Executable File

#!/bin/sh
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. "$(dirname "$0")/sxmo_common.sh"
# Takes 4 args:
# (1) the filepath of the notification to write (or random to generate a random id)
# (2) action notification invokes upon selecting
# (3) the file to watch for deactivation.
# (4) description of notification
NOTIFFILEPATHTOWRITE="$1"
ACTION="$2"
WATCHFILE="$3"
NOTIFMSG="$4"
writenotification() {
mkdir -p "$SXMO_NOTIFDIR"
if [ "$NOTIFFILEPATHTOWRITE" = "random" ]; then
NOTIFRANDOM="$(tr -dc 'a-zA-Z0-9' < /dev/urandom 2>/dev/null | head -c 10)"
NOTIFFILEPATHTOWRITE="$SXMO_NOTIFDIR/$NOTIFRANDOM"
fi
touch "$NOTIFFILEPATHTOWRITE"
printf "%s\n%s\n%b\n" \
"$ACTION" "$WATCHFILE" "$NOTIFMSG" \
> "$NOTIFFILEPATHTOWRITE"
}
[ "$#" -lt 4 ] && echo "Need >=4 args to create a notification" && exit 1
writenotification
sxmo_hook_statusbar.sh notifications