merge
This commit is contained in:
commit
71e3182988
4 changed files with 122 additions and 0 deletions
|
|
@ -3,12 +3,19 @@ set -e
|
|||
[ -n "$DEBUG" ] && set -x
|
||||
|
||||
# loc=$1
|
||||
<<<<<<< HEAD
|
||||
# loc="45.4208,-75.6901"
|
||||
=======
|
||||
loc="Ottawa"
|
||||
>>>>>>> 20ba2d87f75cbe6dd8d7ce93c4f6be43dcc59bfe
|
||||
if [ -z "${loc}" ]; then
|
||||
# use /etc/localtime
|
||||
# loc=$(basename "$(readlink -f /etc/localtime)")
|
||||
# loc="${HOME_LAT},${HOME_LON}"
|
||||
<<<<<<< HEAD
|
||||
# loc="45.4208,-75.6901"
|
||||
=======
|
||||
>>>>>>> 20ba2d87f75cbe6dd8d7ce93c4f6be43dcc59bfe
|
||||
loc="Ottawa"
|
||||
fi
|
||||
|
||||
|
|
|
|||
48
hyprland/.config/waybar/modules/weather2.sh
Executable file
48
hyprland/.config/waybar/modules/weather2.sh
Executable file
|
|
@ -0,0 +1,48 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
[ -n "$DEBUG" ] && set -x
|
||||
|
||||
# loc=$1
|
||||
loc="Ottawa"
|
||||
if [ -z "${loc}" ]; then
|
||||
loc="Ottawa"
|
||||
fi
|
||||
|
||||
if [ -n "$REPORT" ]; then
|
||||
curl -s v2.wttr.in/"${loc}"?F | less
|
||||
exit 0
|
||||
fi
|
||||
|
||||
data="$(curl -s wttr.in/"${loc}"?format=j1)"
|
||||
|
||||
class=
|
||||
case "$(echo "${data}" | jq -r '.current_condition[].weatherCode')" in
|
||||
113) class="sunny" ;;
|
||||
116) class="partlycloudy" ;;
|
||||
119) class="cloudy" ;;
|
||||
122) class="verycloudy" ;;
|
||||
143|248|260) class="fog" ;;
|
||||
176|263|266|293|296|353) class="lightrain" ;;
|
||||
179|182|185|281|284|311|314|317|350|362|365|374|377) class="hail" ;;
|
||||
200|386|389|392) class="thunder" ;;
|
||||
227|320) class="lightsnow" ;;
|
||||
230|329|332|335|338|371|395) class="heavysnow" ;;
|
||||
299|302|305|308|356|359) class="heavyrain" ;;
|
||||
323|326|368) class="snowrain" ;;
|
||||
esac
|
||||
|
||||
tooltip="$(curl -s v2.wttr.in/"${loc}"?ATFQ | tail -n5)"
|
||||
|
||||
# Print header
|
||||
#printf "%-20s %-10s %-10s %-10s\n" "Description" "Temperature" "Class" "Tooltip"
|
||||
#printf "%-20s %-10s %-10s %-10s\n" "------------" "-----------" "-----" "-------"
|
||||
|
||||
# Print weather data
|
||||
echo "${data}" | jq --raw-output \
|
||||
--arg class "${class}" \
|
||||
--arg tooltip "$tooltip" \
|
||||
'.current_condition[] |
|
||||
{ desc: .weatherDesc[0].value, temp: (.temp_C | tonumber), class: $class, tooltip: $tooltip } |
|
||||
"\(.desc)\t\(.temp)\t\(.class)\t\(.tooltip)"' | \
|
||||
awk -F '\t' '{ printf "%-20s %-10s %-10s %-10s\n", $1, $2, $3, $4 }'
|
||||
|
||||
31
hyprland/.config/waybar/modules/weather3.sh
Executable file
31
hyprland/.config/waybar/modules/weather3.sh
Executable file
|
|
@ -0,0 +1,31 @@
|
|||
#! /usr/bin/env bash
|
||||
# If you source this file, it will set WTTR_PARAMS as well as show weather.
|
||||
|
||||
# WTTR_PARAMS is space-separated URL parameters, many of which are single characters that can be
|
||||
# lumped together. For example, "F q m" behaves the same as "Fqm".
|
||||
if [[ -z "$WTTR_PARAMS" ]]; then
|
||||
# Form localized URL parameters for curl
|
||||
if [[ -t 1 ]] && [[ "$(tput cols)" -lt 125 ]]; then
|
||||
WTTR_PARAMS+='n'
|
||||
fi 2> /dev/null
|
||||
for _token in $( locale LC_MEASUREMENT ); do
|
||||
case $_token in
|
||||
1) WTTR_PARAMS+='m' ;;
|
||||
2) WTTR_PARAMS+='u' ;;
|
||||
esac
|
||||
done 2> /dev/null
|
||||
unset _token
|
||||
export WTTR_PARAMS
|
||||
fi
|
||||
|
||||
wttr() {
|
||||
local location="${1// /+}"
|
||||
command shift
|
||||
local args=""
|
||||
for p in $WTTR_PARAMS "$@"; do
|
||||
args+=" --data-urlencode $p "
|
||||
done
|
||||
curl -fGsS -H "Accept-Language: ${LANG%_*}" $args --compressed "wttr.in/${location}"
|
||||
}
|
||||
|
||||
wttr "$@"
|
||||
36
hyprland/.config/waybar/modules/weather_info.sh
Executable file
36
hyprland/.config/waybar/modules/weather_info.sh
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Specify your location (e.g., London or London,GB)
|
||||
LOCATION="your_location_here"
|
||||
|
||||
# Fetch weather data from wttr.in
|
||||
RESPONSE=$(curl -s "wttr.in/${LOCATION}?format=1")
|
||||
|
||||
# Fetch additional detailed weather information
|
||||
DETAIL=$(curl -s "wttr.in/${LOCATION}?format=%C+%t+%w+%p+%S")
|
||||
|
||||
# Parse the response
|
||||
CONDITION=$(echo "$DETAIL" | awk '{print $1}')
|
||||
TEMP=$(echo "$DETAIL" | awk '{print $2}')
|
||||
WIND=$(echo "$DETAIL" | awk '{print $3}')
|
||||
PRESSURE=$(echo "$DETAIL" | awk '{print $4}')
|
||||
SUNRISE=$(echo "$DETAIL" | awk '{print $5}' | cut -d' ' -f1)
|
||||
SUNSET=$(echo "$DETAIL" | awk '{print $5}' | cut -d' ' -f2)
|
||||
|
||||
# FontAwesome icons (replace with actual icons as needed)
|
||||
ICON_CONDITION="☀️" # Use a default icon
|
||||
if [[ "$CONDITION" == *"🌧"* ]]; then
|
||||
ICON_CONDITION="🌧️"
|
||||
elif [[ "$CONDITION" == *"☀"* ]]; then
|
||||
ICON_CONDITION="☀️"
|
||||
elif [[ "$CONDITION" == *"🌤"* ]]; then
|
||||
ICON_CONDITION="🌤️"
|
||||
fi
|
||||
|
||||
ICON_WIND="🌬️" # Wind icon
|
||||
ICON_PRESSURE="🌡️" # Pressure icon
|
||||
ICON_SUNRISE="🌅" # Sunrise icon
|
||||
ICON_SUNSET="🌇" # Sunset icon
|
||||
|
||||
# Output the weather information
|
||||
echo "$ICON_CONDITION $TEMP, $ICON_WIND $WIND, $ICON_PRESSURE $PRESSURE, $ICON_SUNRISE $SUNRISE, $ICON_SUNSET $SUNSET"
|
||||
Loading…
Add table
Reference in a new issue