mpv & change wallpaper

This commit is contained in:
2025-08-01 15:13:29 +02:00
parent 8c96a0f4c0
commit eeb268b632
89 changed files with 10963 additions and 15985 deletions

View File

@@ -29,19 +29,19 @@ UNITS=metric
## Make cache dir
if [[ ! -d "$cache_dir" ]]; then
mkdir -p ${cache_dir}
mkdir -p "${cache_dir}"
fi
## Get data
get_weather_data() {
weather=`curl -sf "http://api.openweathermap.org/data/3.0/onecall?lat=${LAT}&lon=${LON}&exclude=minutely,hourly,daily&appid=${KEY}&units=${UNITS}"`
echo ${weather} >&2
weather=$(curl -sf "http://api.openweathermap.org/data/3.0/onecall?lat=${LAT}&lon=${LON}&exclude=minutely,hourly,daily&appid=${KEY}&units=${UNITS}")
echo "${weather}" >&2
weather=$(echo "$weather" | jq -r ".current")
if [ ! -z "$weather" ]; then
weather_temp=`echo "$weather" | jq ".temp" | cut -d "." -f 1`
weather_icon_code=`echo "$weather" | jq -r ".weather[].icon" | head -1`
weather_description=`echo "$weather" | jq -r ".weather[].description" | head -1 | sed -e "s/\b\(.\)/\u\1/g"`
if [ -n "$weather" ]; then
weather_temp=$(echo "$weather" | jq ".temp" | cut -d "." -f 1)
weather_icon_code=$(echo "$weather" | jq -r ".weather[].icon" | head -1)
weather_description=$(echo "$weather" | jq -r ".weather[].description" | head -1 | sed -e "s/\b\(.\)/\u\1/g")
#Big long if statement of doom
if [ "$weather_icon_code" == "50d" ]; then
@@ -108,17 +108,17 @@ get_weather_data() {
weather_icon=" "
weather_hex="#c0caf5"
fi
echo "$weather_icon" > ${cache_weather_icon}
echo "$weather_description" > ${cache_weather_stat}
echo "$weather_temp""°C" > ${cache_weather_degree}
echo "$weather_hex" > ${cache_weather_hex}
date "+%Y-%m-%d %H:%M:%S" | tee ${cache_weather_updatetime} >/dev/null
echo "$weather_icon" > "${cache_weather_icon}"
echo "$weather_description" > "${cache_weather_stat}"
echo "$weather_temp""°C" > "${cache_weather_degree}"
echo "$weather_hex" > "${cache_weather_hex}"
date "+%Y-%m-%d %H:%M:%S" | tee "${cache_weather_updatetime}" >/dev/null
else
echo "Weather Unavailable" > ${cache_weather_stat}
echo " " > ${cache_weather_icon}
echo "-" > ${cache_weather_degree}
echo "#adadff" > ${cache_weather_hex}
date "+%Y-%m-%d %H:%M:%S" | tee ${cache_weather_updatetime} >/dev/null
echo "Weather Unavailable" > "${cache_weather_stat}"
echo " " > "${cache_weather_icon}"
echo "-" > "${cache_weather_degree}"
echo "#adadff" > "${cache_weather_hex}"
date "+%Y-%m-%d %H:%M:%S" | tee "${cache_weather_updatetime}" >/dev/null
fi
}
@@ -145,13 +145,13 @@ if [[ "$1" == "--getdata" ]]; then
get_weather_data
fi
elif [[ "$1" == "--icon" ]]; then
cat ${cache_weather_icon}
cat "${cache_weather_icon}"
elif [[ "$1" == "--temp" ]]; then
cat ${cache_weather_degree}
cat "${cache_weather_degree}"
elif [[ "$1" == "--hex" ]]; then
tail -F ${cache_weather_hex}
tail -F "${cache_weather_hex}"
elif [[ "$1" == "--stat" ]]; then
cat ${cache_weather_stat}
cat "${cache_weather_stat}"
elif [[ "$1" == "--updatetime" ]]; then
cat ${cache_weather_updatetime}
cat "${cache_weather_updatetime}"
fi