21 lines
683 B
Bash
21 lines
683 B
Bash
#!/bin/sh
|
|||
|
|
# Config -> Sync GPS time: set the system clock from GNSS only and report it.
|
||
|
|
# Runs as the X session user; the GPS helper escalates the clock step itself.
|
||
|
|
set -u
|
||
|
|
|
||
|
|
HELPER="${BANANARCHY_GPS_TIME_HELPER:-/usr/bin/bananarchy-gps-time-sync.sh}"
|
||
|
|
result="$("$HELPER" sync 2>&1)"
|
||
|
|
[ -n "$result" ] || result="No response from the GPS time helper"
|
||
|
|
|
||
|
|
case "$result" in
|
||
|
|
"GPS time synced"*) urgency=normal ;;
|
||
|
|
*) urgency=critical ;;
|
||
|
|
esac
|
||
|
|
|
||
|
|
if command -v notify-send >/dev/null 2>&1; then
|
||
|
|
notify-send --urgency="$urgency" --expire-time=8000 \
|
||
|
|
"Sync GPS time" "$result" >/dev/null 2>&1 || true
|
||
|
|
else
|
||
|
|
sxmo_notify_user.sh "Sync GPS time: $result" >/dev/null 2>&1 || true
|
||
|
|
fi
|
||
|
|
exit 0
|