aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/UserScripts
diff options
context:
space:
mode:
authorprabinpanta0 <pantaprabin30@gmail.com>2025-10-27 10:32:36 +0545
committerprabinpanta0 <pantaprabin30@gmail.com>2025-10-27 10:32:36 +0545
commit95b85dd6c59620d660ff320a07bdf7b3c42bdc46 (patch)
tree457ee13a13e729c784e0dbfd440c34529b3c90e7 /config/hypr/UserScripts
parentf876fc42308b949e791e6f685fa9c6f32605667e (diff)
config(hypr): disable tooltip markup by default, refine place handling & simple output; replace wttr wrapper
- Set TOOLTIP_MARKUP default to off (ENV-driven still supported). - Use truthy checks in place extraction helpers and simplify extraction logic. - Change place formatting to show resolved place with coordinates or coordinates-only. - Prepend place to simple text cache and add icons for wind, humidity and visibility. - Replace legacy wttr-based Weather.sh with a direct Python Weather.py invocation.
Diffstat (limited to 'config/hypr/UserScripts')
-rwxr-xr-xconfig/hypr/UserScripts/Weather.py28
-rwxr-xr-xconfig/hypr/UserScripts/Weather.sh86
2 files changed, 19 insertions, 95 deletions
diff --git a/config/hypr/UserScripts/Weather.py b/config/hypr/UserScripts/Weather.py
index 3c5d58f9..3b58d8ff 100755
--- a/config/hypr/UserScripts/Weather.py
+++ b/config/hypr/UserScripts/Weather.py
@@ -74,7 +74,7 @@ MANUAL_PLACE: Optional[str] = None
# Location icon in tooltip (default to a standard emoji to avoid missing glyphs)
LOC_ICON = os.getenv("WEATHER_LOC_ICON", "📍")
# Enable/disable Pango markup in tooltip (1/0, true/false)
-TOOLTIP_MARKUP = os.getenv("WEATHER_TOOLTIP_MARKUP", "1").lower() not in ("0", "false", "no")
+TOOLTIP_MARKUP = os.getenv("WEATHER_TOOLTIP_MARKUP", "0").lower() not in ("0", "false", "no")
# Optional debug logging to stderr (set WEATHER_DEBUG=1 to enable)
DEBUG = os.getenv("WEATHER_DEBUG", "0").lower() not in ("0", "false", "no")
@@ -416,11 +416,11 @@ def extract_place_parts_nominatim(data_dict: JSONDict) -> List[str]:
admin1 = cast(Optional[str], address.get("state"))
country = cast(Optional[str], address.get("country"))
parts: List[str] = []
- if name is not None:
+ if name:
parts.append(name)
- if admin1 is not None:
+ if admin1:
parts.append(admin1)
- if country is not None:
+ if country:
parts.append(country)
return parts
@@ -430,9 +430,12 @@ def extract_place_parts_open_meteo(p: JSONDict) -> List[str]:
admin1 = cast(Optional[str], p.get("admin1"))
country = cast(Optional[str], p.get("country"))
parts: List[str] = []
- for part in [name, admin1, country]:
- if part is not None:
- parts.append(part)
+ if name:
+ parts.append(name)
+ if admin1:
+ parts.append(admin1)
+ if country:
+ parts.append(country)
return parts
@@ -641,7 +644,9 @@ def build_aqi_info(aqi: Optional[Dict[str, Any]]) -> str:
def build_place_str(lat: float, lon: float, place: Optional[str]) -> str:
- return MANUAL_PLACE or ENV_PLACE or place or f"{lat:.3f}, {lon:.3f}"
+ if place:
+ return f"{place} ({lat:.3f}, {lon:.3f})"
+ return f"{lat:.3f}, {lon:.3f}"
@@ -752,11 +757,12 @@ def build_output(loc: Location, forecast: Optional[Dict[str, Any]], aqi: Optiona
}
simple_weather = (
+ f"{place_str}\n"
f"{data.icon} {data.status}\n"
+ f" {data.temp_str} ({data.feels_str})\n"
- + (f"{data.wind_text} \n" if data.wind_text else "")
- + (f"{data.humidity_text} \n" if data.humidity_text else "")
- + f"{data.visibility_text} {data.aqi_text}\n"
+ + (f" {data.wind_text} \n" if data.wind_text else "")
+ + (f" {data.humidity_text} \n" if data.humidity_text else "")
+ + f" {data.visibility_text} {data.aqi_text}\n"
)
return out_data, simple_weather
diff --git a/config/hypr/UserScripts/Weather.sh b/config/hypr/UserScripts/Weather.sh
index 9bdaff4a..744878a9 100755
--- a/config/hypr/UserScripts/Weather.sh
+++ b/config/hypr/UserScripts/Weather.sh
@@ -1,87 +1,5 @@
#!/bin/bash
# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ##
-# weather info from wttr. https://github.com/chubin/wttr.in
-# Remember to add city
+# weather info using Python script with Open-Meteo APIs
-city=
-cachedir="$HOME/.cache/rbn"
-cachefile=${0##*/}-$1
-
-if [ ! -d $cachedir ]; then
- mkdir -p $cachedir
-fi
-
-if [ ! -f $cachedir/$cachefile ]; then
- touch $cachedir/$cachefile
-fi
-
-# Save current IFS
-SAVEIFS=$IFS
-# Change IFS to new line.
-IFS=$'\n'
-
-cacheage=$(($(date +%s) - $(stat -c '%Y' "$cachedir/$cachefile")))
-if [ $cacheage -gt 1740 ] || [ ! -s $cachedir/$cachefile ]; then
- data=($(curl -s https://en.wttr.in/"$city"$1\?0qnT 2>&1))
- echo ${data[0]} | cut -f1 -d, > $cachedir/$cachefile
- echo ${data[1]} | sed -E 's/^.{15}//' >> $cachedir/$cachefile
- echo ${data[2]} | sed -E 's/^.{15}//' >> $cachedir/$cachefile
-fi
-
-weather=($(cat $cachedir/$cachefile))
-
-# Restore IFSClear
-IFS=$SAVEIFS
-
-temperature=$(echo ${weather[2]} | sed -E 's/([[:digit:]]+)\.\./\1 to /g')
-
-#echo ${weather[1]##*,}
-
-# https://fontawesome.com/icons?s=solid&c=weather
-case $(echo ${weather[1]##*,} | tr '[:upper:]' '[:lower:]') in
-"clear" | "sunny")
- condition=""
- ;;
-"partly cloudy")
- condition="󰖕"
- ;;
-"cloudy")
- condition=""
- ;;
-"overcast")
- condition=""
- ;;
-"fog" | "freezing fog")
- condition=""
- ;;
-"patchy rain possible" | "patchy light drizzle" | "light drizzle" | "patchy light rain" | "light rain" | "light rain shower" | "mist" | "rain")
- condition="󰼳"
- ;;
-"moderate rain at times" | "moderate rain" | "heavy rain at times" | "heavy rain" | "moderate or heavy rain shower" | "torrential rain shower" | "rain shower")
- condition=""
- ;;
-"patchy snow possible" | "patchy sleet possible" | "patchy freezing drizzle possible" | "freezing drizzle" | "heavy freezing drizzle" | "light freezing rain" | "moderate or heavy freezing rain" | "light sleet" | "ice pellets" | "light sleet showers" | "moderate or heavy sleet showers")
- condition="󰼴"
- ;;
-"blowing snow" | "moderate or heavy sleet" | "patchy light snow" | "light snow" | "light snow showers")
- condition="󰙿"
- ;;
-"blizzard" | "patchy moderate snow" | "moderate snow" | "patchy heavy snow" | "heavy snow" | "moderate or heavy snow with thunder" | "moderate or heavy snow showers")
- condition=""
- ;;
-"thundery outbreaks possible" | "patchy light rain with thunder" | "moderate or heavy rain with thunder" | "patchy light snow with thunder")
- condition=""
- ;;
-*)
- condition=""
- echo -e "{\"text\":\""$condition"\", \"alt\":\""${weather[0]}"\", \"tooltip\":\""${weather[0]}: $temperature ${weather[1]}"\"}"
- ;;
-esac
-
-#echo $temp $condition
-
-echo -e "{\"text\":\""$temperature $condition"\", \"alt\":\""${weather[0]}"\", \"tooltip\":\""${weather[0]}: $temperature ${weather[1]}"\"}"
-
-cached_weather=" $temperature \n$condition ${weather[1]}"
-
-echo -e $cached_weather > "$HOME/.cache/.weather_cache" \ No newline at end of file
+python3 "$(dirname "$0")/Weather.py" \ No newline at end of file
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage