-
-
Save henrik242/1da3a252ca66fb7d17bca5509a67937f to your computer and use it in GitHub Desktop.
| #!/usr/bin/env bash | |
| # | |
| # Reads AirTag data from the FindMy.app cache and converts it to a daily GPX file | |
| # | |
| # Rsyncs the data to a web accessible folder that can be displayed with e.g. | |
| # https://gist.github.com/henrik242/84ad80dd2170385fe819df1d40224cc4 | |
| # | |
| # This should typically be run as a cron job | |
| # | |
| set -o pipefail -o nounset -o errexit | |
| export PATH=/usr/local/bin:$PATH | |
| DATADIR=/tmp/airtag-data | |
| TODAY=$(date +%d) | |
| mkdir -p $DATADIR | |
| DATA=$DATADIR/airtagdata-$TODAY.txt | |
| GPX=$DATADIR/airtagdata-$TODAY.gpx | |
| TAGNAME=Foobar | |
| if [[ $(uname -s) == "Darwin" ]]; then | |
| TOMORROW=$(date -v +1d +%d) | |
| else | |
| TOMORROW=$(date --date="tomorrow" +%d) | |
| fi | |
| rm -f $DATADIR/airtagdata-$TOMORROW.gpx | |
| jq -r '.[] | select(.name == "'$TAGNAME'") | .location | "\(.latitude) \(.longitude) \(.altitude) \(.timeStamp/1000 | todate)"' \ | |
| $HOME/Library/Caches/com.apple.findmy.fmipcore/Items.data >> $DATA | |
| START='<?xml version="1.0" encoding="UTF-8"?> | |
| <gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:mytracks="http://mytracks.stichling.info/myTracksGPX/1/0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" creator="myTracks" version="1.1" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"> | |
| <trk> | |
| <name>'$TAGNAME'</name> | |
| <extensions> | |
| <mytracks:color red="0.000000" green="0.000000" blue="1.000000" alpha="1.000000" /> | |
| <mytracks:area showArea="no" areaDistance="0.000000" /> | |
| <mytracks:directionArrows showDirectionArrows="yes" /> | |
| <mytracks:sync syncPhotosOniPhone="no" /> | |
| <mytracks:timezone offset="120" /> | |
| </extensions> | |
| <trkseg>' | |
| END=' </trkseg> | |
| </trk> | |
| </gpx>' | |
| echo $START > $GPX | |
| function elems() { | |
| LAT=$1 | |
| LON=$2 | |
| ELE=$3 | |
| TS=$4 | |
| } | |
| cat $DATA | while read line; do | |
| elems $line | |
| echo '<trkpt lat="'$LAT'" lon="'$LON'"> | |
| <ele>'$ELE'</ele> | |
| <time>'$TS'</time> | |
| </trkpt>' >> $GPX | |
| done | |
| echo $END >> $GPX | |
| cp $GPX $DATADIR/airtagdata.gpx | |
| rsync -a --exclude='*.txt' $DATADIR example.com:public_html/airtag/ |
2026 YAY!! I finally found a use for the 27" iMac I got for free!!! Can't update past Ventura making it more useless every day other than a Safari DoomScroller. AND NOW it just sits with this script running in my closet to log all my location history. Please don't let Apple screw this up and somehow make it not function anymore.
FYI. I am a Windows/Samsung Lifer user who just switched over to an all Apple System when Google took it too far by making Samsung eliminate another app (Samsung Text) I know it is not a huge deal but it won't be long before Google gobbles up Samsung and destroys the last remaining bits of separation with Android from Google. Why would anyone choose a Google trying to act like Apple when they can have Apple. Still like Windows better but that may change when I finally get a Mac that isn't stuck in the past.
To start the script: (For whatever reason there is no instructions in the original post on how to start it if you shut down the computer.)
cd ~/FindMyHistory
python3 main.py
(Must be running in Terminal and computer can never sleep that it is running on so you may want to lock up your computer if you don’t want anyone to be able to access your account since you must be logged in and have it open. Maybe someone can make a fix to this?)
Also, there are some issues with the code that maybe need updated but thankfully Google Ai search helped me get past them. Here are the ones that I had to fix with Google Ai:
(Copy and past the Fixed code into Terminal, do not click if they come up as links.)
Install AttrubuteError:
git clone https://github.com/fjxmlzn/FindMyHistory.git
cd FindMyHistory
pip3 install -r requirements.txt
python3 main.py
Fixed:
git clone https://github.com/fjxmlzn/FindMyHistory.git
cd FindMyHistory
pip3 install -r requirements.txt
pip3 install --upgrade typing_extensions
python3 main.py
Help Doesn't work:
python3 main.py --help
Fixed:
cd ~/FindMyHistory
python3 main.py --help
Any other issues just type into Google Ai if you are a dumb dumb like me.
Searching and finding answers, the only thing I trust Google for.
If you want to leave it running in the background this seems to work: (still have to keep Find My open but you can close Terminal.
Quick Cheat Sheet for Managing It
Whenever you open Terminal in the future, keep these three commands handy:
- To see it running: (screen -r history_tracker)
- To hide it back into the background: Press Ctrl + A, then tap D.
- To shut it down completely: Reattach to it (screen -r history_tracker), press Ctrl + C to stop the script, and type exit to close the session.
Hi guys! I've download the Mac OS Sonoma 14.3.1 img file and wrote it to an USB drive with Balena Etcher. However on installation i'm required to have internet and after the installation my Mac Mini has Sonoma 14.8 which is a newer version than the image. Can somebody guide me to install 14.3.1 without having an internet connection or without having it updated to 14.8? Thanks a lot. hdo