forked from lawleagle/oled-linux
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget-current-location.sh
executable file
·44 lines (31 loc) · 983 Bytes
/
get-current-location.sh
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
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
cd "$(dirname ${BASH_SOURCE[0]})"
#location of where-am-i from geoclue2 demos
where_am_i='/usr/lib/geoclue-2.0/demos/where-am-i'
if ! test -f $where_am_i
then
echo "ERROR: Dependency 'where-am-i' from geoclue2 demo files is not located properly. Please install geoclue2 or update file location in this script"
kill -9 $PPID
exit 0
fi
while true
do
$where_am_i > file-pipes/where-am-i-result.txt
latitude=`cat file-pipes/where-am-i-result.txt | grep -m 1 Latitude | awk '{FS=":";print $2}' | sed 's/?//g'`
longitude=`cat file-pipes/where-am-i-result.txt | grep -m 1 Longitude | awk '{FS=":";print $2}' | sed 's/?//g'`
if (( $(echo "$latitude < 0" | bc -l) ))
then
latitude_suffix='S'
else
latitude_suffix='N'
fi
if (( $(echo "$longitude < 0" | bc -l) ))
then
longitude_suffix='W'
else
longitude_suffix='E'
fi
echo "${latitude}${latitude_suffix} ${longitude}${longitude_suffix}" > file-pipes/current-location.txt
exit 0
sleep 10m
done