gps_watch_onconnect.sh 1022 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #! /bin/bash -eu
  2. # Copyright (C) 2014 mru@sisyphus.teil.cc
  3. # this is only an example.
  4. # called by the gps_watch_monitor.py when the watch is connected.
  5. # starts the watch client to import new tracks, starts mytourbook
  6. # to customize this script,
  7. # copy it to ~/.gps_watch_onconnect.sh and modify it to suit your needs.
  8. #serial_device=$1
  9. destdir=$HOME/rides
  10. mkdir -p $destdir
  11. mkdir -p $destdir/images
  12. cd $destdir
  13. now_fn=$(date +%F_%T | tr ':' '_')
  14. trap '{
  15. echo "failed to receive watch data";
  16. }' ERR
  17. sleep 1
  18. # echo "downloading MTK7d.EPO"
  19. # echo
  20. # curl -u krippl-gps-master:master -o MTK7d.EPO ftp://ftp.krippl-watches.com/AGPS/MTK7d.EPO
  21. # echo
  22. echo "importing data"
  23. echo
  24. crane_gps_watch_client --verbose --split --clear
  25. echo
  26. # start mytourbook
  27. tb=~/opt/tourbook/mytourbook/mytourbook
  28. if [[ -z "$(pgrep -f $tb)" ]]; then
  29. # if mytourbook is not started, start it
  30. echo "starting $tb"
  31. nohup $tb &
  32. else
  33. # else bring it to front
  34. wmctrl -a $(basename $tb) || true
  35. fi
  36. wait
  37. echo
  38. echo "completed"