summaryrefslogtreecommitdiffstats
path: root/.config/polybar/scripts/space
diff options
context:
space:
mode:
Diffstat (limited to '.config/polybar/scripts/space')
-rwxr-xr-x.config/polybar/scripts/space31
1 files changed, 31 insertions, 0 deletions
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 @@
1#!/usr/bin/env bash
2
3# Ankara & Eskisehir are about 200kms away long/lat wise;
4#
5# Ank: 39.925533, 32.866287
6# Esk: 39.766193, 30.526714.
7#
8# That's about 2.34 diff in longitude (much less in latitude), multiply by 100,
9# get rid of the floating part (round down aggressively), 200 seems like a good
10# margin, that's probably within Ankara borders
11#
12# The API recommends calling every 5 seconds (not more frequently, please!), 30
13# seems fine
14#
15# Coords below are from the METU hoodie :)
16
17LEEWAY=200
18
19response=$(curl -s http://api.open-notify.org/iss-now.json)
20
21lat=$(echo "${response}"| jq '.iss_position.latitude')
22long=$(echo "${response}"| jq '.iss_position.longitude')
23
24distlat=$(perl -e "print int(100 * abs(${lat} - 39.885833))")
25distlong=$(perl -e "print int(100 * abs(${long} - 32.779444))")
26
27if [ $distlat -lt $LEEWAY ] && [ $distlong -lt $LEEWAY ]; then
28 echo ""
29else
30 echo
31fi