-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrapper.sh
executable file
·36 lines (29 loc) · 998 Bytes
/
wrapper.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
stderr () {
echo "$1" >&2
}
echo_date () {
echo `date` $1
}
LOGFILE="$HOME/git-sync.log"
if command -v "termux-info" &>/dev/null ; then
NOTIF_CMD="termux-notification"
NOTIF_ERROR="$NOTIF_CMD -t git-sync -c ERROR --id error --ongoing"
NOTIF_START="$NOTIF_CMD -t git-sync_started"
elif [ "$(uname -m)" == "armv7l" ]; then
NOTIF_CMD=echo_date
NOTIF_ERROR="$NOTIF_CMD git-sync ERROR -t 0"
NOTIF_START="$NOTIF_CMD git-sync_started"
else
NOTIF_CMD="notify-send"
NOTIF_ERROR="$NOTIF_CMD git-sync ERROR -t 0"
NOTIF_START="$NOTIF_CMD git-sync_started"
fi
command -v "$NOTIF_CMD" &>/dev/null || { stderr "Error: Required command '$NOTIF_CMD' not found"; exit 1; }
test $GIT_SYNC_DIRECTORY && cd $GIT_SYNC_DIRECTORY
while true; do
# Sometimes notifications take some time (minutes) when restarting the phone
# To avoid blocking git-sync, spawn a new process
$NOTIF_START &
./git-sync.sh >> $LOGFILE 2>&1 || ($NOTIF_ERROR &)
done