Make sure shellcheck passes and fixup style in sxmo_gpsutil.sh script
This commit is contained in:
parent
9709accd13
commit
1d13cb6379
4 changed files with 87 additions and 98 deletions
|
@ -2,7 +2,7 @@
|
||||||
menu() {
|
menu() {
|
||||||
pidof svkbd-sxmo || svkbd-sxmo &
|
pidof svkbd-sxmo || svkbd-sxmo &
|
||||||
SEARCHTERMS="$(
|
SEARCHTERMS="$(
|
||||||
echo "Close Menu\n" |
|
echo "Close Menu" |
|
||||||
dmenu -p "Yt Search" -c -l 10 -fn Terminus-20
|
dmenu -p "Yt Search" -c -l 10 -fn Terminus-20
|
||||||
)"
|
)"
|
||||||
pkill svkbd-sxmo
|
pkill svkbd-sxmo
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
SXMO_GPSLOCATIONSFILE="/usr/share/sxmo/places_for_gps.tsv"
|
SXMO_GPSLOCATIONSFILE="/usr/share/sxmo/places_for_gps.tsv"
|
||||||
EDITOR=vis
|
|
||||||
CTILESIZE=256
|
CTILESIZE=256
|
||||||
CLN2=0.693147180559945309417
|
CLN2=0.693147180559945309417
|
||||||
CPI=3.14159265358979323846
|
CPI=3.14159265358979323846
|
||||||
|
@ -54,7 +53,7 @@ px2lon() {
|
||||||
|
|
||||||
killexistingfoxtrotgps() {
|
killexistingfoxtrotgps() {
|
||||||
ACTIVEWIN="$(xdotool getactivewindow)"
|
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
|
if echo "$WMCLASS" | grep -i foxtrot; then
|
||||||
xdotool windowkill "$ACTIVEWIN" && return 0
|
xdotool windowkill "$ACTIVEWIN" && return 0
|
||||||
return 1
|
return 1
|
||||||
|
@ -68,32 +67,31 @@ gpslatlonget() {
|
||||||
Y="$(gsettings get org.foxtrotgps global-y)"
|
Y="$(gsettings get org.foxtrotgps global-y)"
|
||||||
X="$(gsettings get org.foxtrotgps global-x)"
|
X="$(gsettings get org.foxtrotgps global-x)"
|
||||||
WINH="$(
|
WINH="$(
|
||||||
xwininfo -id $(xdotool getactivewindow) | grep -E '^\s*Height' | cut -d: -f2
|
xwininfo -id "$(xdotool getactivewindow)" | grep -E '^\s*Height' | cut -d: -f2
|
||||||
)"
|
)"
|
||||||
WINW="$(
|
WINW="$(
|
||||||
xwininfo -id $(xdotool getactivewindow) | grep -E '^\s*Width' | cut -d: -f2
|
xwininfo -id "$(xdotool getactivewindow)" | grep -E '^\s*Width' | cut -d: -f2
|
||||||
)"
|
)"
|
||||||
LAT="$(px2lat "$(echo "$Y + ($WINH / 2)" | bc -l)" "$ZOOM")"
|
LAT="$(px2lat "$(echo "$Y + ($WINH / 2)" | bc -l)" "$ZOOM")"
|
||||||
LON="$(px2lon "$(echo "$X + ($WINW / 2)" | bc -l)" "$ZOOM")"
|
LON="$(px2lon "$(echo "$X + ($WINW / 2)" | bc -l)" "$ZOOM")"
|
||||||
echo "$LAT" "$LON" "$ZOOM"
|
echo "$LAT" "$LON" "$ZOOM"
|
||||||
}
|
}
|
||||||
gpslatlonset() {
|
gpslatlonset() {
|
||||||
CORDS="$(echo "$@" | tr -d ',°')"
|
CORDS="$(echo $@ | tr -d ',°')"
|
||||||
CURRENTPOS="$(echo $CORDS | cut -d' ' -f1)"
|
LAT="$(echo "$CORDS" | cut -d' ' -f1)"
|
||||||
LAT="$(echo $CORDS | cut -d' ' -f1)"
|
LON="$(echo "$CORDS" | cut -d' ' -f2)"
|
||||||
LON="$(echo $CORDS | cut -d' ' -f2)"
|
ZOOM="$(echo "$CORDS" | cut -d' ' -f3)"
|
||||||
ZOOM="$(echo $CORDS | cut -d' ' -f3)"
|
|
||||||
[ -z "$ZOOM" ] && ZOOM=10
|
[ -z "$ZOOM" ] && ZOOM=10
|
||||||
WINW="$(
|
WINW="$(
|
||||||
xwininfo -id $(xdotool getactivewindow) | grep -E '^\s*Width' | cut -d: -f2
|
xwininfo -id "$(xdotool getactivewindow)" | grep -E '^\s*Width' | cut -d: -f2
|
||||||
)"
|
)"
|
||||||
WINH="$(
|
WINH="$(
|
||||||
xwininfo -id $(xdotool getactivewindow) | grep -E '^\s*Height' | cut -d: -f2
|
xwininfo -id "$(xdotool getactivewindow)" | grep -E '^\s*Height' | cut -d: -f2
|
||||||
)"
|
)"
|
||||||
|
|
||||||
# Translate lat&lon into pixel values
|
# Translate lat&lon into pixel values
|
||||||
Y="$(echo "$(lat2px $LAT $ZOOM) - ($WINH / 2)" | bc -l | cut -d. -f1)"
|
Y="$(echo "$(lat2px "$LAT" "$ZOOM") - ($WINH / 2)" | bc -l | cut -d. -f1)"
|
||||||
X="$(echo "$(lon2px $LON $ZOOM) - ($WINW / 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-zoom "$ZOOM"
|
||||||
gsettings set org.foxtrotgps global-x "$X"
|
gsettings set org.foxtrotgps global-x "$X"
|
||||||
|
@ -101,10 +99,8 @@ gpslatlonset() {
|
||||||
killexistingfoxtrotgps && st -e foxtrotgps --lat="$LAT" --lon="$LON" &
|
killexistingfoxtrotgps && st -e foxtrotgps --lat="$LAT" --lon="$LON" &
|
||||||
}
|
}
|
||||||
gpsgeoclueget() {
|
gpsgeoclueget() {
|
||||||
# Retrieves latlon from geoclue
|
# Will retrieve and set latlon from geoclue
|
||||||
echo foo
|
echo foo
|
||||||
#gsettings set org.foxtrotgps myposition-lat "$LAT"
|
|
||||||
#gsettings set org.foxtrotgps myposition-lon "$LON"
|
|
||||||
}
|
}
|
||||||
copy() {
|
copy() {
|
||||||
COORDS="$(gpslatlonget)"
|
COORDS="$(gpslatlonget)"
|
||||||
|
@ -123,15 +119,15 @@ droppin() {
|
||||||
|
|
||||||
details() {
|
details() {
|
||||||
COORDS="$(gpslatlonget)"
|
COORDS="$(gpslatlonget)"
|
||||||
LAT="$(echo $COORDS | cut -d' ' -f1)"
|
LAT="$(echo "$COORDS" | cut -d' ' -f1)"
|
||||||
LON="$(echo $COORDS | cut -d' ' -f2)"
|
LON="$(echo "$COORDS" | cut -d' ' -f2)"
|
||||||
ZOOM="$(echo $COORDS | cut -d' ' -f3)"
|
ZOOM="$(echo "$COORDS" | cut -d' ' -f3)"
|
||||||
surf -S "https://nominatim.openstreetmap.org/reverse.php?lat=${LAT}&lon=${LON}&zoom=${ZOOM}&format=html" &
|
surf -S "https://nominatim.openstreetmap.org/reverse.php?lat=${LAT}&lon=${LON}&zoom=${ZOOM}&format=html" &
|
||||||
}
|
}
|
||||||
|
|
||||||
menuregionsearch() {
|
menuregionsearch() {
|
||||||
WINH="$(xwininfo -id $(xdotool getactivewindow) | grep -E '^\s*Height' | 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)"
|
WINW="$(xwininfo -id "$(xdotool getactivewindow)" | grep -E '^\s*Width' | cut -d: -f2)"
|
||||||
|
|
||||||
POIS="
|
POIS="
|
||||||
Close Menu
|
Close Menu
|
||||||
|
@ -140,7 +136,6 @@ menuregionsearch() {
|
||||||
Restaurant
|
Restaurant
|
||||||
Pizza
|
Pizza
|
||||||
Barbershop
|
Barbershop
|
||||||
Barber
|
|
||||||
"
|
"
|
||||||
QUERY="$(
|
QUERY="$(
|
||||||
printf %b "$POIS" |
|
printf %b "$POIS" |
|
||||||
|
@ -169,21 +164,16 @@ menulocations() {
|
||||||
printf %b "$(
|
printf %b "$(
|
||||||
echo "Close Menu";
|
echo "Close Menu";
|
||||||
cat "$SXMO_GPSLOCATIONSFILE";
|
cat "$SXMO_GPSLOCATIONSFILE";
|
||||||
echo "Edit"
|
|
||||||
)" |
|
)" |
|
||||||
grep -vE '^#' |
|
grep -vE '^#' |
|
||||||
sed "s/\t/: /g" |
|
sed "s/\t/: /g" |
|
||||||
sxmo_dmenu_with_kb.sh -i -c -l 10 -fn Terminus-18 -p "Locations"
|
sxmo_dmenu_with_kb.sh -i -c -l 10 -fn Terminus-18 -p "Locations"
|
||||||
)"
|
)"
|
||||||
ZOOM=14
|
ZOOM=14
|
||||||
|
if [ "$CHOICE" = "Close Menu" ]; then
|
||||||
if [ $CHOICE = "Edit" ]; then
|
|
||||||
RES="$(st -e $EDITOR "$SXMO_GPSLOCATIONSFILE")"
|
|
||||||
exit 0
|
|
||||||
elif [ "$CHOICE" = "Close Menu" ]; then
|
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
LATLON="$(echo -e "$CHOICE" | cut -d: -f2- )"
|
LATLON="$(printf %b "$CHOICE" | cut -d: -f2- )"
|
||||||
gpslatlonset "$LATLON $ZOOM"
|
gpslatlonset "$LATLON $ZOOM"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -214,4 +204,4 @@ menumaptype() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
$@
|
"$1" "$2" "$3" "$4" "$5"
|
|
@ -10,12 +10,11 @@ update() {
|
||||||
if pgrep -f sxmo_modemcall.sh; then
|
if pgrep -f sxmo_modemcall.sh; then
|
||||||
NOWS="$(date +"%s")"
|
NOWS="$(date +"%s")"
|
||||||
CALLSTARTS="$(date +"%s" -d "$(
|
CALLSTARTS="$(date +"%s" -d "$(
|
||||||
cat ~/.config/sxmo/modem/modemlog.tsv |
|
grep call_start ~/.config/sxmo/modem/modemlog.tsv |
|
||||||
grep call_start |
|
|
||||||
tail -n1 |
|
tail -n1 |
|
||||||
cut -f1
|
cut -f1
|
||||||
)")"
|
)")"
|
||||||
CALLSECONDS="$(echo $NOWS - $CALLSTARTS | bc)"
|
CALLSECONDS="$(echo "$NOWS" - "$CALLSTARTS" | bc)"
|
||||||
CALLINFO=" ${CALLSECONDS}s "
|
CALLINFO=" ${CALLSECONDS}s "
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
# Env vars
|
# Env vars
|
||||||
# shellcheck disable=SC1091
|
# shellcheck disable=SC1091
|
||||||
. /etc/profile
|
. /etc/profile
|
||||||
which "$TERM" || export TERM=st
|
command -v "$TERM" || export TERM=st
|
||||||
which "$BROWSER" || export BROWSER=surf
|
command -v "$BROWSER" || export BROWSER=surf
|
||||||
[ -z "$MOZ_USE_XINPUT2" ] && export MOZ_USE_XINPUT2=1
|
[ -z "$MOZ_USE_XINPUT2" ] && export MOZ_USE_XINPUT2=1
|
||||||
[ -z "$XDG_CONFIG_HOME" ] && export XDG_CONFIG_HOME=~/.config
|
[ -z "$XDG_CONFIG_HOME" ] && export XDG_CONFIG_HOME=~/.config
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue