my-scripts/gammastep-init.sh

24 lines
719 B
Bash
Raw Normal View History

2022-09-19 02:13:02 +00:00
#!/bin/sh
#run this to start gammastep
#got this from https://rumpelsepp.org/blog/geolocation-for-gammastep/
#modified to be a posix shell script, and to save location data to a file
#so gammastep still works if internet is out.
JSFN="$HOME/.cache/gs_geoclue.json"
2022-09-19 02:13:02 +00:00
FN="$HOME/.cache/gs_geoclue.txt"
2022-12-16 05:07:37 +00:00
curl -Ls https://ipapi.co/json > "$JSFN".tmp
#dont update file if error received, could also check if an error flag is present
if [ "$(cat "$JSFN".tmp | wc -l)" -gt 4 ]; then
mv "$JSFN".tmp "$JSFN"
LAT="$( cat "$JSFN" | jq ".latitude" )"
LONG="$( cat "$JSFN" | jq ".longitude" )"
echo "$LAT $LONG" > "$FN"
fi
gammastep -l "$( cat "$FN" | cut -d' ' -f1)":"$( cat "$FN" | cut -d' ' -f2)" -m wayland