From 7d02d49ee5dd8c43b72cd50cd00a6e9de79f74ed Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Sun, 31 Oct 2021 16:29:10 +0300 Subject: polybar: iss tracker (spaaaace) --- .config/polybar/scripts/space | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 .config/polybar/scripts/space (limited to '.config/polybar/scripts/space') diff --git a/.config/polybar/scripts/space b/.config/polybar/scripts/space new file mode 100755 index 0000000..af5060a --- /dev/null +++ b/.config/polybar/scripts/space @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +# Ankara & Eskisehir are about 200kms away long/lat wise; +# +# Ank: 39.925533, 32.866287 +# Esk: 39.766193, 30.526714. +# +# That's about 2.34 diff in longitude (much less in latitude), multiply by 100, +# get rid of the floating part (round down aggressively), 200 seems like a good +# margin, that's probably within Ankara borders +# +# The API recommends calling every 5 seconds (not more frequently, please!), 30 +# seems fine +# +# Coords below are from the METU hoodie :) + +LEEWAY=200 + +response=$(curl -s http://api.open-notify.org/iss-now.json) + +lat=$(echo "${response}"| jq '.iss_position.latitude') +long=$(echo "${response}"| jq '.iss_position.longitude') + +distlat=$(perl -e "print int(100 * abs(${lat} - 39.885833))") +distlong=$(perl -e "print int(100 * abs(${long} - 32.779444))") + +if [ $distlat -lt $LEEWAY ] && [ $distlong -lt $LEEWAY ]; then + echo "" +else + echo +fi -- cgit v1.2.3-70-g09d2