individual API keys for status bar :(

This commit is contained in:
spinach 2023-01-15 15:16:54 -05:00
parent 1a9f6c189f
commit bc690b60d3

View File

@ -33,7 +33,8 @@ exit $1
WORKING_DIR="$HOME/.local/share/weather"
WEATHER_FILE="$WORKING_DIR/.env"
WEATHER_CALL="ssh spinach@git.keegandeppe.com weather"
# URL
WEATHER_CALL="https://api.openweathermap.org/data/2.5/weather?lat=$LAT&lon=$LON&appid=$API_KEY&units=$UNITS"
TIMEOUT=60 # timeout for info
TIME=$(date +%s)
@ -81,10 +82,10 @@ check_expiration() {
get_location() {
# searching for user location
if [[ -n "$SEARCH" ]] ; then
LOCATION_CALL="https://api.openweathermap.org/data/2.5/weather?$SEARCH&appid=$API_KEY"
g if [[ -n "$SEARCH" ]] ; then
# search
RESULTS=$($WEATHER_CALL -s "$SEARCH" | gojq "del(.[].local_names)")
RESULTS=$($(curl --silent -fL "$LOCATION_CALL") | gojq "del(.[].local_names)")
NUM_RESULTS=$(echo "$RESULTS" | gojq '. | length')
SELECTION=0
@ -188,6 +189,7 @@ get_weather() {
save_info() {
# saves set env vars to files
printf '%s\n' \
"API_KEY=$API_KEY"
"LAT=$LAT" \
"LON=$LON" \
"CITY=$CITY" \
@ -204,6 +206,11 @@ load_info() {
save_info
fi
source $WEATHER_FILE
if [[ -z "$API_KEY" ]] ; then
echo "No API Key found!"
exit 1
fi
}
get_icon() {
@ -299,10 +306,10 @@ while getopts "chpiz:s:u:" opt; do
UNIT="$OPTARG"
;;
'z' )
[ -n "$ZIPCODE" ] && usage 1 || ZIPCODE="$OPTARG"
[ -n "$ZIPCODE" ] && usage 1 || ZIPCODE="zip=$OPTARG"
;;
's' )
[ -n "$SEARCH" ] && usage 1 || SEARCH="$OPTARG"
[ -n "$SEARCH" ] && usage 1 || SEARCH="q=$OPTARG"
;;
'p' )
PRETTY=true