Mostly working weather image, now for source selection

master
Steven Saus 3 years ago
parent 406dece087
commit de9bade13f
  1. BIN
      weather_image/archive(1).zip
  2. BIN
      weather_image/archive.zip
  3. BIN
      weather_image/icons/01d.png
  4. BIN
      weather_image/icons/01n.png
  5. BIN
      weather_image/icons/02d.png
  6. BIN
      weather_image/icons/02n.png
  7. BIN
      weather_image/icons/03d.png
  8. BIN
      weather_image/icons/03n.png
  9. BIN
      weather_image/icons/04d.png
  10. BIN
      weather_image/icons/04n.png
  11. BIN
      weather_image/icons/09d.png
  12. BIN
      weather_image/icons/09n.png
  13. BIN
      weather_image/icons/10d.png
  14. BIN
      weather_image/icons/10n.png
  15. BIN
      weather_image/icons/11d.png
  16. BIN
      weather_image/icons/11n.png
  17. BIN
      weather_image/icons/13d.png
  18. BIN
      weather_image/icons/13n.png
  19. BIN
      weather_image/icons/50d.png
  20. BIN
      weather_image/icons/50n.png
  21. 4
      weather_image/icons/readme.txt
  22. 117
      weather_image/weather.sh
  23. 33
      weather_image/weather_image.sh

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

@ -0,0 +1,4 @@
Iconset: Weather Color (https://www.iconfinder.com/iconsets/weather-color-2)
Author: Sihan Liu (https://www.iconfinder.com/Neolau1119)
License: Free for commercial use ()
Download date: 2021-10-26

@ -4,10 +4,6 @@
apiKey=""
defaultLocation=""
Conky="False"
OpenBox="False"
Terminal="False"
HTML="False"
degreeCharacter="c"
data=0
lastUpdateTime=0
@ -16,7 +12,9 @@ dynamicUpdates=0
UseIcons="True"
colors="False"
CityID="True"
icondata=""
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
ConfigFile="$HOME/.config/weather_sh.rc"
if [ "$1" == "-r" ];then
@ -56,14 +54,6 @@ option="$1"
shift ;;
-d) dynamicUpdates=1
shift ;;
-t) Terminal="True"
shift ;;
-h) HTML="True"
shift ;;
-o) OpenBox="True"
shift ;;
-y) Conky="True"
shift ;;
-f) degreeCharacter="f"
shift ;;
-p) CachePath="$2"
@ -142,7 +132,7 @@ while true; do
####################################################################
# Current conditions (and icon)
####################################################################
if [ "$UseIcons" = "True" ];then
icons=$(echo $data | jq -r .weather[].icon | tr '\n' ' ')
iconval=${icons%?}
case $iconval in
@ -156,9 +146,6 @@ while true; do
13*) icon="🌨";;
50*) icon="🌫";;
esac
else
icon=""
fi
ShortWeather=$(echo $data | jq -r .weather[].main | tr '\n' ' '| awk '{$1=$1};1' )
LongWeather=$(echo $data | jq -r .weather[].description | sed -E 's/\S+/\u&/g' | tr '\n' ' '| awk '{$1=$1};1' )
@ -249,92 +236,20 @@ while true; do
pressureunit="hPa"
fi
fi
AsOf=$(date +"%Y-%m-%d %R" -d @$lastfileupdate)
if [ "$OpenBox" = "False" ];then
if [ "$HTML" = "False" ];then
if [ "$Conky" = "False" ];then
Terminal="True"
fi
fi
fi
if [ "$Terminal" = "True" ];then
if [ "$colors" = "True" ]; then
echo "Station: $Station, $Country $Lat / $Long"
echo "As Of: ${YELLOW}$AsOf ${RESTORE}"
echo "Right Now: ${CYAN}$icon $LongWeather${RESTORE}"
#echo "$icon $ShortWeather"
echo "Temp: ${CYAN}$temperature°${degreeCharacter^^}${RESTORE}"
if [ "$FeelsLike" = "1" ];then
echo "Feels Like: ${RED}$FeelsLikeTemp°${degreeCharacter^^}${RESTORE}"
fi
echo "Pressure: ${GREEN}$pressure$pressureunit${RESTORE}"
if [ "$UseIcons" = "True" ];then
echo -e \\u$winddir "${MAGENTA}$WindSpeed$windunit${RESTORE} Gusts: ${MAGENTA}$WindGusts$windunit${RESTORE}"
else
echo "Wind: ${MAGENTA}$WindSpeed$windunit${RESTORE} Gusts: ${MAGENTA}$WindGusts$windunit${RESTORE}"
fi
echo "Humidity: ${GREEN}$Humidity%${RESTORE}"
echo "Cloud Cover: ${GREEN}$CloudCover%${RESTORE}"
else
echo "Station: $Station, $Country $Lat / $Long"
echo "As Of: $AsOf "
echo "Right Now: $icon $LongWeather"
#echo "$icon $ShortWeather"
echo "Temp: $temperature°${degreeCharacter^^}"
if [ "$FeelsLike" = "1" ];then
echo "Feels Like: $FeelsLikeTemp°${degreeCharacter^^}"
fi
echo "Pressure: $pressure$pressureunit"
echo -e \\u$winddir "$WindSpeed$windunit Gusts: $WindGusts$windunit"
echo "Humidity: $Humidity%"
echo "Cloud Cover: $CloudCover%"
fi
fi
if [ "$Conky" = "True" ]; then
if [ "$colors" = "True" ]; then
bob=$(echo "$ShortWeather $temperature°${degreeCharacter^^}")
if [ "$FeelsLike" = "1" ];then
bob=$(echo "$bob/$FeelsLikeTemp°${degreeCharacter^^}")
fi
else
bob=$(echo "$ShortWeather $temperature°${degreeCharacter^^}")
if [ "$FeelsLike" = "1" ];then
bob=$(echo "$bob/$FeelsLikeTemp°${degreeCharacter^^}")
fi
fi
echo "$bob"
fi
if [ "$OpenBox" = "True" ]; then
echo '<openbox_pipe_menu>'
echo '<separator label="Weather" />'
printf '<item label="Station: %s, %s" />\n' "$Station" "$Country"
printf '<item label="As of %s" />\n' "$AsOf"
printf '<item label="Now: %s %s" />\n' "$icon" "$LongWeather"
printf '<item label="Temp: %s%s" />\n' "$temperature" "°${degreeCharacter^^}"
if [ "$FeelsLike" = "1" ];then
printf '<item label="Feels Like: %s%s" />\n' "$FeelsLikeTemp" "°${degreeCharacter^^}"
fi
printf '<item label="Pressure: %s%s" />\n' "$pressure" "$pressureunit"
printf '<item label="Wind: %s%s Gusts: %s%s" />\n' "$WindSpeed" "$windunit" "$WindGusts" "$windunit"
printf '<item label="Humidity: %s%%" />\n' "$Humidity"
printf '<item label="Cloud Cover: %s%%" />\n' "$CloudCover"
echo '</openbox_pipe_menu>'
fi
if [ "$HTML" = "True" ];then
echo "Station: $Station, $Country $Lat / $Long <br />"
echo "As Of: $AsOf <br />"
echo "Current Conditions: $icon $LongWeather <br />"
#echo "$icon $ShortWeather"
echo "Temp: $temperature °${degreeCharacter^^} <br />"
if [ "$FeelsLike" = "1" ];then
echo "Feels Like: $FeelsLikeTemp °${degreeCharacter^^} <br />"
fi
echo "Pressure: $pressure $pressureunit <br />"
echo -e \\u$winddir "$WindSpeed$windunit Gusts: $WindGusts$windunit <br />"
echo "Humidity: $Humidity% <br />"
echo "Cloud Cover: $CloudCover% <br />"
#AsOf=$(date +"%Y-%m-%d %R" -d @$lastfileupdate)
echo "${iconval}"
NowTime=$(date +"%H:%M")
echo "${LongWeather} at ${NowTime}"
if [ "$FeelsLike" = "1" ];then
echo "$temperature deg ${degreeCharacter^^}, Feels $FeelsLikeTemp deg ${degreeCharacter^^}"
else
echo "Temp: $temperature deg ${degreeCharacter^^}"
fi
echo "Pressure: $pressure$pressureunit"
echo "$WindSpeed$windunit ($WindGusts$windunit)"
echo "Humidity: $Humidity%"
echo "Cloud Cover: $CloudCover%"
if [ $dynamicUpdates -eq 0 ];then
break
fi

@ -13,21 +13,42 @@ declare Fortune
#create tempfile2 (for text image )
#TempDir=$(mktemp -d)
TempDir=/home/steven/tmp
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
#cp ${SCRIPT_DIR}/${icons%?}.png
################################################################################
# Wherein things get told to happen
################################################################################
main() {
bob=`wget https://picsum.photos/1920/1080/?random -O $TempDir/unsplash.jpg`
convert $TempDir/unsplash.jpg -blur 0x3 $TempDir/unsplash_blur.jpg
Fortune=$(/home/steven/bin/weather.sh -n | tail -6 | sed 's/°/ deg /g' | sed 's/\x1B\[[0-9;]\{1,\}[A-Za-z]//g' | grep -v "Cache")
/usr/bin/convert -background none -fill white -stroke black -strokewidth 2 -gravity Southeast -font Interstate -size 1920x400 \
caption:"$Fortune" \
# Obtain source image
bob=`wget https://picsum.photos/1920/1080/?random -O $TempDir/unsplash.jpg`
# Blur, if desired.
convert $TempDir/unsplash.jpg -blur 0x3 $TempDir/unsplash_blur.jpg
# Get our text and make it into an image
DataInfo=$(${SCRIPT_DIR}/weather.sh | grep -v "Cache")
IconData=$(echo "$DataInfo" | head -1)
TextData=$(echo "$DataInfo" | tail -6)
cp ${SCRIPT_DIR}/icons/"$IconData".png ${TempDir}/WeatherIcon.png
/usr/bin/convert -background none -fill white -stroke black -strokewidth 2 -gravity Southeast -font Abydos -size 800x400 \
caption:"$TextData" \
-gravity Southwest \
$TempDir/TextImage.png
/usr/bin/composite -gravity Southwest $TempDir/TextImage.png $TempDir/unsplash_blur.jpg $TempDir/weather_background.jpg
# Applying the appropriate icon to the image. This has to be done in
# steps for the transparency to keep working.
/usr/bin/composite -gravity Center $TempDir/WeatherIcon.png -gravity Southwest $TempDir/TextImage.png $TempDir/Text_Icon.png
# Applying the text and icon to the base image.
/usr/bin/composite -gravity Southeast $TempDir/Text_Icon.png $TempDir/unsplash_blur.jpg $TempDir/weather.jpg

Loading…
Cancel
Save