summaryrefslogtreecommitdiffstats
path: root/.config/polybar/scripts/space
blob: af5060a8f829e665c36a6a7af9eda646104f8537 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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