|
|
|
@ -1,6 +1,5 @@ |
|
|
|
|
#!/usr/bin/env sh |
|
|
|
|
SXMO_GPSLOCATIONSFILE="/usr/share/sxmo/places_for_gps.tsv" |
|
|
|
|
EDITOR=vis |
|
|
|
|
CTILESIZE=256 |
|
|
|
|
CLN2=0.693147180559945309417 |
|
|
|
|
CPI=3.14159265358979323846 |
|
|
|
@ -10,51 +9,51 @@ CPI=3.14159265358979323846 |
|
|
|
|
# foxtrotgps doesn't support autocentering on restored lat/lon instead it |
|
|
|
|
# stores internally X/Y pixel values; so we need conversion fns |
|
|
|
|
lat2px() { |
|
|
|
|
DEGREES="$1"; ZOOM="$2" |
|
|
|
|
echo " |
|
|
|
|
define atanh(x) { return((l(1 + x) - l(1 - x))/2) }; |
|
|
|
|
-( \ |
|
|
|
|
atanh(s(($DEGREES * $CPI / 180))) * \ |
|
|
|
|
$CTILESIZE * e($ZOOM * $CLN2) / (2 * $CPI) \ |
|
|
|
|
) + (e($ZOOM * $CLN2) * ($CTILESIZE / 2))\ |
|
|
|
|
" | bc -l |
|
|
|
|
DEGREES="$1"; ZOOM="$2" |
|
|
|
|
echo " |
|
|
|
|
define atanh(x) { return((l(1 + x) - l(1 - x))/2) }; |
|
|
|
|
-( \ |
|
|
|
|
atanh(s(($DEGREES * $CPI / 180))) * \ |
|
|
|
|
$CTILESIZE * e($ZOOM * $CLN2) / (2 * $CPI) \ |
|
|
|
|
) + (e($ZOOM * $CLN2) * ($CTILESIZE / 2))\ |
|
|
|
|
" | bc -l |
|
|
|
|
} |
|
|
|
|
lon2px() { |
|
|
|
|
DEGREES="$1"; ZOOM="$2" |
|
|
|
|
echo " |
|
|
|
|
( \ |
|
|
|
|
($DEGREES * $CPI / 180) * $CTILESIZE * \ |
|
|
|
|
e($ZOOM * $CLN2) / (2 * $CPI) \ |
|
|
|
|
) + (e($ZOOM * $CLN2) * ($CTILESIZE / 2)) |
|
|
|
|
" | bc -l |
|
|
|
|
DEGREES="$1"; ZOOM="$2" |
|
|
|
|
echo " |
|
|
|
|
( \ |
|
|
|
|
($DEGREES * $CPI / 180) * $CTILESIZE * \ |
|
|
|
|
e($ZOOM * $CLN2) / (2 * $CPI) \ |
|
|
|
|
) + (e($ZOOM * $CLN2) * ($CTILESIZE / 2)) |
|
|
|
|
" | bc -l |
|
|
|
|
} |
|
|
|
|
px2lat() { |
|
|
|
|
PX="$1"; ZOOM="$2" |
|
|
|
|
echo " |
|
|
|
|
define asin(x) { |
|
|
|
|
if(x==1) return($CPI/2); if(x==-1) return(-$CPI/2); return(a(x/sqrt(1-(x^2)))); |
|
|
|
|
} |
|
|
|
|
define tanh(x) { auto t;t=e(x+x)-1;return(t/(t+2)) } |
|
|
|
|
asin(tanh( \ |
|
|
|
|
(-( $PX - ( e( $ZOOM * $CLN2 ) * ( $CTILESIZE / 2 ) ) ) * ( 2 * $CPI )) / \ |
|
|
|
|
( $CTILESIZE * e( $ZOOM * $CLN2)) \ |
|
|
|
|
)) / $CPI * 180 |
|
|
|
|
" | bc -l |
|
|
|
|
PX="$1"; ZOOM="$2" |
|
|
|
|
echo " |
|
|
|
|
define asin(x) { |
|
|
|
|
if(x==1) return($CPI/2); if(x==-1) return(-$CPI/2); return(a(x/sqrt(1-(x^2)))); |
|
|
|
|
} |
|
|
|
|
define tanh(x) { auto t;t=e(x+x)-1;return(t/(t+2)) } |
|
|
|
|
asin(tanh( \ |
|
|
|
|
(-( $PX - ( e( $ZOOM * $CLN2 ) * ( $CTILESIZE / 2 ) ) ) * ( 2 * $CPI )) / \ |
|
|
|
|
( $CTILESIZE * e( $ZOOM * $CLN2)) \ |
|
|
|
|
)) / $CPI * 180 |
|
|
|
|
" | bc -l |
|
|
|
|
} |
|
|
|
|
px2lon() { |
|
|
|
|
PX="$1"; ZOOM="$2" |
|
|
|
|
echo " |
|
|
|
|
( \ |
|
|
|
|
($PX - (e($ZOOM * $CLN2) * ($CTILESIZE / 2))) * 2 * $CPI / \ |
|
|
|
|
($CTILESIZE * e($ZOOM * $CLN2)) \ |
|
|
|
|
) / $CPI * 180 |
|
|
|
|
" | bc -l |
|
|
|
|
PX="$1"; ZOOM="$2" |
|
|
|
|
echo " |
|
|
|
|
( \ |
|
|
|
|
($PX - (e($ZOOM * $CLN2) * ($CTILESIZE / 2))) * 2 * $CPI / \ |
|
|
|
|
($CTILESIZE * e($ZOOM * $CLN2)) \ |
|
|
|
|
) / $CPI * 180 |
|
|
|
|
" | bc -l |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
killexistingfoxtrotgps() { |
|
|
|
|
ACTIVEWIN="$(xdotool getactivewindow)" |
|
|
|
|
WMCLASS="${1:-$(xprop -id $ACTIVEWIN | grep WM_CLASS | cut -d ' ' -f3-)}" |
|
|
|
|
WMCLASS="$(xprop -id "$ACTIVEWIN" | grep WM_CLASS | cut -d ' ' -f3-)" |
|
|
|
|
if echo "$WMCLASS" | grep -i foxtrot; then |
|
|
|
|
xdotool windowkill "$ACTIVEWIN" && return 0 |
|
|
|
|
return 1 |
|
|
|
@ -64,47 +63,44 @@ killexistingfoxtrotgps() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
gpslatlonget() { |
|
|
|
|
ZOOM="$(gsettings get org.foxtrotgps global-zoom)" |
|
|
|
|
Y="$(gsettings get org.foxtrotgps global-y)" |
|
|
|
|
X="$(gsettings get org.foxtrotgps global-x)" |
|
|
|
|
WINH="$( |
|
|
|
|
xwininfo -id $(xdotool getactivewindow) | grep -E '^\s*Height' | cut -d: -f2 |
|
|
|
|
)" |
|
|
|
|
WINW="$( |
|
|
|
|
xwininfo -id $(xdotool getactivewindow) | grep -E '^\s*Width' | cut -d: -f2 |
|
|
|
|
)" |
|
|
|
|
LAT="$(px2lat "$(echo "$Y + ($WINH / 2)" | bc -l)" "$ZOOM")" |
|
|
|
|
LON="$(px2lon "$(echo "$X + ($WINW / 2)" | bc -l)" "$ZOOM")" |
|
|
|
|
echo "$LAT" "$LON" "$ZOOM" |
|
|
|
|
ZOOM="$(gsettings get org.foxtrotgps global-zoom)" |
|
|
|
|
Y="$(gsettings get org.foxtrotgps global-y)" |
|
|
|
|
X="$(gsettings get org.foxtrotgps global-x)" |
|
|
|
|
WINH="$( |
|
|
|
|
xwininfo -id "$(xdotool getactivewindow)" | grep -E '^\s*Height' | cut -d: -f2 |
|
|
|
|
)" |
|
|
|
|
WINW="$( |
|
|
|
|
xwininfo -id "$(xdotool getactivewindow)" | grep -E '^\s*Width' | cut -d: -f2 |
|
|
|
|
)" |
|
|
|
|
LAT="$(px2lat "$(echo "$Y + ($WINH / 2)" | bc -l)" "$ZOOM")" |
|
|
|
|
LON="$(px2lon "$(echo "$X + ($WINW / 2)" | bc -l)" "$ZOOM")" |
|
|
|
|
echo "$LAT" "$LON" "$ZOOM" |
|
|
|
|
} |
|
|
|
|
gpslatlonset() { |
|
|
|
|
CORDS="$(echo "$@" | tr -d ',°')" |
|
|
|
|
CURRENTPOS="$(echo $CORDS | cut -d' ' -f1)" |
|
|
|
|
LAT="$(echo $CORDS | cut -d' ' -f1)" |
|
|
|
|
LON="$(echo $CORDS | cut -d' ' -f2)" |
|
|
|
|
ZOOM="$(echo $CORDS | cut -d' ' -f3)" |
|
|
|
|
[ -z "$ZOOM" ] && ZOOM=10 |
|
|
|
|
WINW="$( |
|
|
|
|
xwininfo -id $(xdotool getactivewindow) | grep -E '^\s*Width' | cut -d: -f2 |
|
|
|
|
)" |
|
|
|
|
WINH="$( |
|
|
|
|
xwininfo -id $(xdotool getactivewindow) | grep -E '^\s*Height' | cut -d: -f2 |
|
|
|
|
)" |
|
|
|
|
CORDS="$(echo $@ | tr -d ',°')" |
|
|
|
|
LAT="$(echo "$CORDS" | cut -d' ' -f1)" |
|
|
|
|
LON="$(echo "$CORDS" | cut -d' ' -f2)" |
|
|
|
|
ZOOM="$(echo "$CORDS" | cut -d' ' -f3)" |
|
|
|
|
[ -z "$ZOOM" ] && ZOOM=10 |
|
|
|
|
WINW="$( |
|
|
|
|
xwininfo -id "$(xdotool getactivewindow)" | grep -E '^\s*Width' | cut -d: -f2 |
|
|
|
|
)" |
|
|
|
|
WINH="$( |
|
|
|
|
xwininfo -id "$(xdotool getactivewindow)" | grep -E '^\s*Height' | cut -d: -f2 |
|
|
|
|
)" |
|
|
|
|
|
|
|
|
|
# Translate lat&lon into pixel values |
|
|
|
|
Y="$(echo "$(lat2px $LAT $ZOOM) - ($WINH / 2)" | bc -l | cut -d. -f1)" |
|
|
|
|
X="$(echo "$(lon2px $LON $ZOOM) - ($WINW / 2)" | bc -l | cut -d. -f1)" |
|
|
|
|
# Translate lat&lon into pixel values |
|
|
|
|
Y="$(echo "$(lat2px "$LAT" "$ZOOM") - ($WINH / 2)" | bc -l | cut -d. -f1)" |
|
|
|
|
X="$(echo "$(lon2px "$LON" "$ZOOM") - ($WINW / 2)" | bc -l | cut -d. -f1)" |
|
|
|
|
|
|
|
|
|
gsettings set org.foxtrotgps global-zoom "$ZOOM" |
|
|
|
|
gsettings set org.foxtrotgps global-x "$X" |
|
|
|
|
gsettings set org.foxtrotgps global-y "$Y" |
|
|
|
|
killexistingfoxtrotgps && st -e foxtrotgps --lat="$LAT" --lon="$LON" & |
|
|
|
|
gsettings set org.foxtrotgps global-zoom "$ZOOM" |
|
|
|
|
gsettings set org.foxtrotgps global-x "$X" |
|
|
|
|
gsettings set org.foxtrotgps global-y "$Y" |
|
|
|
|
killexistingfoxtrotgps && st -e foxtrotgps --lat="$LAT" --lon="$LON" & |
|
|
|
|
} |
|
|
|
|
gpsgeoclueget() { |
|
|
|
|
# Retrieves latlon from geoclue |
|
|
|
|
echo foo |
|
|
|
|
#gsettings set org.foxtrotgps myposition-lat "$LAT" |
|
|
|
|
#gsettings set org.foxtrotgps myposition-lon "$LON" |
|
|
|
|
# Will retrieve and set latlon from geoclue |
|
|
|
|
echo foo |
|
|
|
|
} |
|
|
|
|
copy() { |
|
|
|
|
COORDS="$(gpslatlonget)" |
|
|
|
@ -123,15 +119,15 @@ droppin() { |
|
|
|
|
|
|
|
|
|
details() { |
|
|
|
|
COORDS="$(gpslatlonget)" |
|
|
|
|
LAT="$(echo $COORDS | cut -d' ' -f1)" |
|
|
|
|
LON="$(echo $COORDS | cut -d' ' -f2)" |
|
|
|
|
ZOOM="$(echo $COORDS | cut -d' ' -f3)" |
|
|
|
|
LAT="$(echo "$COORDS" | cut -d' ' -f1)" |
|
|
|
|
LON="$(echo "$COORDS" | cut -d' ' -f2)" |
|
|
|
|
ZOOM="$(echo "$COORDS" | cut -d' ' -f3)" |
|
|
|
|
surf -S "https://nominatim.openstreetmap.org/reverse.php?lat=${LAT}&lon=${LON}&zoom=${ZOOM}&format=html" & |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
menuregionsearch() { |
|
|
|
|
WINH="$(xwininfo -id $(xdotool getactivewindow) | grep -E '^\s*Height' | cut -d: -f2)" |
|
|
|
|
WINW="$(xwininfo -id $(xdotool getactivewindow) | grep -E '^\s*Width' | cut -d: -f2)" |
|
|
|
|
WINH="$(xwininfo -id "$(xdotool getactivewindow)" | grep -E '^\s*Height' | cut -d: -f2)" |
|
|
|
|
WINW="$(xwininfo -id "$(xdotool getactivewindow)" | grep -E '^\s*Width' | cut -d: -f2)" |
|
|
|
|
|
|
|
|
|
POIS=" |
|
|
|
|
Close Menu |
|
|
|
@ -140,7 +136,6 @@ menuregionsearch() { |
|
|
|
|
Restaurant |
|
|
|
|
Pizza |
|
|
|
|
Barbershop |
|
|
|
|
Barber |
|
|
|
|
" |
|
|
|
|
QUERY="$( |
|
|
|
|
printf %b "$POIS" | |
|
|
|
@ -152,14 +147,14 @@ menuregionsearch() { |
|
|
|
|
if [ "$QUERY" = "Close Menu" ]; then |
|
|
|
|
exit 0 |
|
|
|
|
else |
|
|
|
|
ZOOM="$(gsettings get org.foxtrotgps global-zoom)" |
|
|
|
|
Y="$(gsettings get org.foxtrotgps global-y)" |
|
|
|
|
X="$(gsettings get org.foxtrotgps global-x)" |
|
|
|
|
TOP="$(px2lat "$Y" "$ZOOM")" |
|
|
|
|
LEFT="$(px2lon "$X" "$ZOOM")" |
|
|
|
|
RIGHT="$(px2lon "$(echo "$X" + "$WINW" | bc -l)" "$ZOOM")" |
|
|
|
|
BOTTOM="$(px2lat "$(echo "$Y" + "$WINH" | bc -l)" "$ZOOM")" |
|
|
|
|
surf -S "https://nominatim.openstreetmap.org/search.php?q=$QUERY&polygon_geojson=1&viewbox=${LEFT}%2C${TOP}%2C${RIGHT}%2C${BOTTOM}&bounded=1" & |
|
|
|
|
ZOOM="$(gsettings get org.foxtrotgps global-zoom)" |
|
|
|
|
Y="$(gsettings get org.foxtrotgps global-y)" |
|
|
|
|
X="$(gsettings get org.foxtrotgps global-x)" |
|
|
|
|
TOP="$(px2lat "$Y" "$ZOOM")" |
|
|
|
|
LEFT="$(px2lon "$X" "$ZOOM")" |
|
|
|
|
RIGHT="$(px2lon "$(echo "$X" + "$WINW" | bc -l)" "$ZOOM")" |
|
|
|
|
BOTTOM="$(px2lat "$(echo "$Y" + "$WINH" | bc -l)" "$ZOOM")" |
|
|
|
|
surf -S "https://nominatim.openstreetmap.org/search.php?q=$QUERY&polygon_geojson=1&viewbox=${LEFT}%2C${TOP}%2C${RIGHT}%2C${BOTTOM}&bounded=1" & |
|
|
|
|
fi |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -169,21 +164,16 @@ menulocations() { |
|
|
|
|
printf %b "$( |
|
|
|
|
echo "Close Menu"; |
|
|
|
|
cat "$SXMO_GPSLOCATIONSFILE"; |
|
|
|
|
echo "Edit" |
|
|
|
|
)" | |
|
|
|
|
grep -vE '^#' | |
|
|
|
|
sed "s/\t/: /g" | |
|
|
|
|
sxmo_dmenu_with_kb.sh -i -c -l 10 -fn Terminus-18 -p "Locations" |
|
|
|
|
)" |
|
|
|
|
ZOOM=14 |
|
|
|
|
|
|
|
|
|
if [ $CHOICE = "Edit" ]; then |
|
|
|
|
RES="$(st -e $EDITOR "$SXMO_GPSLOCATIONSFILE")" |
|
|
|
|
exit 0 |
|
|
|
|
elif [ "$CHOICE" = "Close Menu" ]; then |
|
|
|
|
if [ "$CHOICE" = "Close Menu" ]; then |
|
|
|
|
exit 0 |
|
|
|
|
else |
|
|
|
|
LATLON="$(echo -e "$CHOICE" | cut -d: -f2- )" |
|
|
|
|
LATLON="$(printf %b "$CHOICE" | cut -d: -f2- )" |
|
|
|
|
gpslatlonset "$LATLON $ZOOM" |
|
|
|
|
fi |
|
|
|
|
} |
|
|
|
@ -214,4 +204,4 @@ menumaptype() { |
|
|
|
|
done |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$@ |
|
|
|
|
"$1" "$2" "$3" "$4" "$5" |