From 14799a7b6a31b895444a13ea32040078a7be8e03 Mon Sep 17 00:00:00 2001 From: hornet <88428122+HornetMaidan@users.noreply.github.com> Date: Wed, 8 Nov 2023 23:52:55 +0600 Subject: [PATCH 1/7] v.0.1 - initial version(beta) --- weather.sh | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 weather.sh diff --git a/weather.sh b/weather.sh new file mode 100644 index 0000000..8476a23 --- /dev/null +++ b/weather.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +#verify if user has jq installed +if ! command -v jq &> /dev/null; then +echo "oww, it seems that you don't have jq JSON pawsew installed... pwease do :3" +echo "apt: sudo apt-get install jq" +echo "pacman: " +echo "xbps: sudo xbps-install -S jq" + exit 1 +fi + +api_key="a6c3cfde026d31b995612c6f169203a7" +ipinfo_key="bd1acc5f04e870" +user_ip=$(curl -s https://ifconfig.me/ip) +#echo $user_ip + +location_info=$(curl -s https://ipinfo.io/$user_ip?token=$ipinfo_key) +#echo $location_info +lat=$(echo "$location_info" | jq -r '.loc' | cut -d ',' -f 1) +lon=$(echo "$location_info" | jq -r '.loc' | cut -d ',' -f 2) + +#echo $lat $lon + + +api_url="https://api.openweathermap.org/data/2.5/weather?lat=$lat&lon=$lon&units=metric&appid=$api_key" +#echo $api_url +weather_data=$(curl -s $api_url) +#echo $weather_data +weather_desc=$(echo $weather_data | jq -r '.weather.[].description') + +city=$(echo $weather_data | jq -r '.name') +if [[ "$city" == "Nur-Sultan" ]] ; then +city='Astana'; +fi + +echo "hewwo $USER! i hope u awe doing gweat today!" +echo "hewe is the cuwwent weathew wepowt fow $city uwu~" +echo "--------------------------------------------" +echo "time: $(date +"%H:%M")" +echo "date: $(date +"%d/%m/%Y")" +echo "weathew: $(echo "$weather_data" | jq -r '.weather[].description')" +echo "tempewature: $(echo "$weather_data" | jq -r '.main.temp')°C" +echo "wind: $(echo "$weather_data" | jq -r '.wind.speed')m/s, azimuth: $(echo "$weather_data" | jq -r '.wind.deg')" +echo "cwouds: $(echo "$weather_data" | jq -r '.clouds.all')%" +echo "--------------------------------------------" +if [[ "$weather_desc" == "clear sky" ]]; then + echo "seems to be a pretty clear sky today!" +elif [[ "$weather_desc" == *"clouds"* ]]; then + echo "some cwouds awe pwesent but it's ok :3 i like cwouds!!!!" +elif [[ "$weather_desc" == *"rain"* ]]; then + echo "looks like it's wainin today, make suwe u bring an umbwella with u :3" +elif [[ "$weather_desc" == *"thunderstorm"* ]]; then + echo "a thundewsowm is coming! pwepawe youwself!" +elif [[ "$weather_desc" == *"snow"* ]]; then + echo "thewe is going to be snow today! be caweful outside~" +elif [[ "$weather_desc" == "fog" || "$weather_desc" == "mist" ]]; then + echo "the fog is coming uwu~" +fi From fcb37355d3b723329681e2f4c3832f428c36c934 Mon Sep 17 00:00:00 2001 From: hornet <88428122+HornetMaidan@users.noreply.github.com> Date: Wed, 8 Nov 2023 23:54:35 +0600 Subject: [PATCH 2/7] updated README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 36a121c..498291a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,6 @@ # weather_bash a simple bash script that fetches a weather report for your location right into your terminal +------------------------------------------------- +this is just a simple script for myself to get the current weather right in terminal, +but feel free to use it as you like, as it is licensed with GNU GPL v.3.0 +a considerable amount of uwu is present From e93d112e4be0aaa205a8b3f3dfcf08ccf1bb627c Mon Sep 17 00:00:00 2001 From: hornet <88428122+HornetMaidan@users.noreply.github.com> Date: Wed, 8 Nov 2023 23:55:02 +0600 Subject: [PATCH 3/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 498291a..7093de2 100644 --- a/README.md +++ b/README.md @@ -2,5 +2,5 @@ a simple bash script that fetches a weather report for your location right into your terminal ------------------------------------------------- this is just a simple script for myself to get the current weather right in terminal, -but feel free to use it as you like, as it is licensed with GNU GPL v.3.0 +but feel free to use it as you like, as it is licensed with GNU GPL v.3.0. a considerable amount of uwu is present From a5b26a9a9428176114e4a057d3c0d4016ad569b9 Mon Sep 17 00:00:00 2001 From: hornet <88428122+HornetMaidan@users.noreply.github.com> Date: Thu, 9 Nov 2023 00:02:46 +0600 Subject: [PATCH 4/7] hotfix - minor --- weather.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weather.sh b/weather.sh index 8476a23..14353e8 100644 --- a/weather.sh +++ b/weather.sh @@ -4,7 +4,7 @@ if ! command -v jq &> /dev/null; then echo "oww, it seems that you don't have jq JSON pawsew installed... pwease do :3" echo "apt: sudo apt-get install jq" -echo "pacman: " +echo "pacman: sudo pacman -S jq" echo "xbps: sudo xbps-install -S jq" exit 1 fi From b2b67b9e2345926a8e6a1ce65d940f7df6bc079d Mon Sep 17 00:00:00 2001 From: hornet <88428122+HornetMaidan@users.noreply.github.com> Date: Thu, 9 Nov 2023 00:45:15 +0600 Subject: [PATCH 5/7] hotfix - resolved error message in the beginning --- weather.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weather.sh b/weather.sh index 14353e8..3d71983 100644 --- a/weather.sh +++ b/weather.sh @@ -26,7 +26,7 @@ api_url="https://api.openweathermap.org/data/2.5/weather?lat=$lat&lon=$lon&units #echo $api_url weather_data=$(curl -s $api_url) #echo $weather_data -weather_desc=$(echo $weather_data | jq -r '.weather.[].description') +weather_desc=$(echo $weather_data | jq -r '.weather[].description') city=$(echo $weather_data | jq -r '.name') if [[ "$city" == "Nur-Sultan" ]] ; then From ffe231029d3712ce62f424cd029405588bdbdbd3 Mon Sep 17 00:00:00 2001 From: hornet <88428122+HornetMaidan@users.noreply.github.com> Date: Thu, 9 Nov 2023 12:38:19 +0600 Subject: [PATCH 6/7] to-do updated --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7093de2..f0143f0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,12 @@ # weather_bash a simple bash script that fetches a weather report for your location right into your terminal ------------------------------------------------- -this is just a simple script for myself to get the current weather right in terminal, -but feel free to use it as you like, as it is licensed with GNU GPL v.3.0. +this is just a simple script for myself to get the current weather right in terminal,\ +but feel free to use it as you like, as it is licensed with GNU GPL v.3.0.\ a considerable amount of uwu is present +------------------------------------------------- +to-do: + +#colorcode the output\ +#automatic detection of packet manager to install jq(at least apt/pacman/xbps/etc..)\ +#uwufy everything From a7106c59da73ad1e1b6eb750a5ff7ac480451ff6 Mon Sep 17 00:00:00 2001 From: hornet <88428122+HornetMaidan@users.noreply.github.com> Date: Thu, 9 Nov 2023 18:40:12 +0600 Subject: [PATCH 7/7] v.0.2 - now with colorcode! ANSI colorcode for output added semi-auto jq installation added(user is prompted with choosing the package manager) a reasonable amount of uwufying has been done --- weather.sh | 70 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 25 deletions(-) diff --git a/weather.sh b/weather.sh index 3d71983..3725043 100644 --- a/weather.sh +++ b/weather.sh @@ -1,12 +1,32 @@ #!/bin/bash +#to-do: +#colorcode the output --- DONE +#automatic detection of packet manager to install jq(at least apt/pacman/xbps/etc..) --- DONE +#uwufy everything --- DONE uwu~ + #verify if user has jq installed if ! command -v jq &> /dev/null; then echo "oww, it seems that you don't have jq JSON pawsew installed... pwease do :3" -echo "apt: sudo apt-get install jq" -echo "pacman: sudo pacman -S jq" -echo "xbps: sudo xbps-install -S jq" - exit 1 +echo "sewect youw packet managew..." +echo "[1] apt" +echo "[2] pacman" +echo "[3] xbps" +echo "[4] yum" +echo "[5] dnf" +echo "[6] brew" +echo "[7] zypper" +read -rp "youw choice: " choice +case $choice in + 1) sudo apt-get update && sudo apt-get install jq ;; + 2) sudo pacman --sync jq ;; + 3) sudo xbps-install -S jq ;; + 4) sudo yum install epel-release && sudo yum install jq ;; + 5) sudo dnf install jq ;; + 6) brew install jq ;; + 7) sudo zypper install jq ;; + *) echo "oww, you've done a fucky wucky! twy again ow install it manually~"; exit 1 ;; + esac fi api_key="a6c3cfde026d31b995612c6f169203a7" @@ -24,35 +44,35 @@ lon=$(echo "$location_info" | jq -r '.loc' | cut -d ',' -f 2) api_url="https://api.openweathermap.org/data/2.5/weather?lat=$lat&lon=$lon&units=metric&appid=$api_key" #echo $api_url -weather_data=$(curl -s $api_url) +weather_data=$(curl -s "$api_url") #echo $weather_data -weather_desc=$(echo $weather_data | jq -r '.weather[].description') +weather_desc=$(echo "$weather_data" | jq -r '.weather[].description') -city=$(echo $weather_data | jq -r '.name') +city=$(echo "$weather_data" | jq -r '.name') if [[ "$city" == "Nur-Sultan" ]] ; then city='Astana'; fi - -echo "hewwo $USER! i hope u awe doing gweat today!" -echo "hewe is the cuwwent weathew wepowt fow $city uwu~" -echo "--------------------------------------------" -echo "time: $(date +"%H:%M")" -echo "date: $(date +"%d/%m/%Y")" -echo "weathew: $(echo "$weather_data" | jq -r '.weather[].description')" -echo "tempewature: $(echo "$weather_data" | jq -r '.main.temp')°C" -echo "wind: $(echo "$weather_data" | jq -r '.wind.speed')m/s, azimuth: $(echo "$weather_data" | jq -r '.wind.deg')" -echo "cwouds: $(echo "$weather_data" | jq -r '.clouds.all')%" -echo "--------------------------------------------" +echo "" +echo -e "\e[37mhewwo \e[35m$USER!\e[37m i hope u awe doing gweat today!\e[0m" +echo -e "\e[37mhewe is the cuwwent weathew wepowt fow \e[32m$city\e[37m uwu~\e[0m" +echo -e "\e[32m--------------------------------------------\e[0m" +echo -e "\e[37mtime: $(date +"%H:%M")\e[37m" +echo -e "date: $(date +"%d/%m/%Y")" +echo -e "weathew: \e[33m\e[5m$(echo "$weather_data" | jq -r '.weather[].description')\e[0m" +echo -e "\e[37mtempewature: \e[37m\e[35m$(echo "$weather_data" | jq -r '.main.temp')°C\e[0m" +echo -e "\e[37mwind: \e[37m\e[36m$(echo "$weather_data" | jq -r '.wind.speed')m/s, azimuth: $(echo "$weather_data" | jq -r '.wind.deg')\e[0m" +echo -e "\e[37mcwouds: \e[37m\e[34m$(echo "$weather_data" | jq -r '.clouds.all')%\e[0m" +echo -e "\e[32m--------------------------------------------\e[0m" if [[ "$weather_desc" == "clear sky" ]]; then - echo "seems to be a pretty clear sky today!" + echo -e "\e[33mseems to be a pwetty cleaw sky today!\e[0m" elif [[ "$weather_desc" == *"clouds"* ]]; then - echo "some cwouds awe pwesent but it's ok :3 i like cwouds!!!!" + echo -e "\e[34msome cwouds awe pwesent but it's ok :3 i like cwouds!!!!\e[0m" elif [[ "$weather_desc" == *"rain"* ]]; then - echo "looks like it's wainin today, make suwe u bring an umbwella with u :3" + echo -e "\e[36mlooks like it's wainin today, make suwe u bwing an umbwella with u :3\\e[0m" elif [[ "$weather_desc" == *"thunderstorm"* ]]; then - echo "a thundewsowm is coming! pwepawe youwself!" + echo -e "\e[31ma thundewsowm is coming! pwepawe youwself!\e[0m" elif [[ "$weather_desc" == *"snow"* ]]; then - echo "thewe is going to be snow today! be caweful outside~" + echo -e "\e[37mthewe is going to be snow today! be caweful outside~\e[0m" elif [[ "$weather_desc" == "fog" || "$weather_desc" == "mist" ]]; then - echo "the fog is coming uwu~" -fi + echo -e "\e[31mthe fog is coming uwu~\e[0m" +fi \ No newline at end of file