From 24f33ec5ea8a5027dea4bd0f75341510f6ae5012 Mon Sep 17 00:00:00 2001 From: NCLanceman Date: Wed, 18 Jun 2025 12:33:00 -0500 Subject: [PATCH] Icon Progress --- __pycache__/iconSelector.cpython-311.pyc | Bin 0 -> 1641 bytes iconSelector.py | 21 ++++++++++++++------- readme.md | 5 ++++- weather.py | 5 ++++- 4 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 __pycache__/iconSelector.cpython-311.pyc diff --git a/__pycache__/iconSelector.cpython-311.pyc b/__pycache__/iconSelector.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..249293914377d39284e05a9f6867fc658901a0ab GIT binary patch literal 1641 zcmZ`(&1)M+6rYiH^}TXn?aFazEW0I+lGuWVB*v+eL)=0yF2p5H4R+Y>Y@|*0L(Ht~ zNGL^zQnn&cT|#;^J*1TUEro3;?J_5o{sRIZ3O@DCN>*emo!xzJ-tYb9?d*GR_7_FT zAQ*rDd%yadjL<*AI2p0w&=fRBdL`|cf)!+%+WkSokWoVSktnN4sE>X>Nc#>7! z1B0?soW~!#6)xE(^MGQzPYuAN1JfZ~782H1>da$0KG{C#`0zRUGx~xSIs`pAUIX-I z1Rst^7@-8e2K>#)_Z+wI2HL&zJl2YN(ujuk5ydZZfF(|0ag0c83jv;*z~d1f)nVX+ z7=kZFcy59(Z=pdnl7Q?cH;-|Vinmb_nu<770l~q?WlQ7_GFG!pk7qRU#Lzu+-(Wlw zrF+|@gz>aU_F$TVG!H?M)@Uj+O$??-C1X%JY%-DBVzGFcochf4nC75|a{C{*XV zx4O54UGn$*y-+>hz1h7f?92YHzZn>|S&0*^(VQ8FusXIMW;Ruw~JlW9y{*V4seB zn$f&C9!qzLu?+v4cM*O?r5K%qI`Xt<+QyfUH?#&5r7RZdhXPhiTdNo+T}w-V&BMb) z?b|5K5`ZUe)LhtsZVW})GgxkzK=#?Ma9?pXi`Lb_z$N8#Qy*Q literal 0 HcmV?d00001 diff --git a/iconSelector.py b/iconSelector.py index 459aed9..8fe1b2a 100644 --- a/iconSelector.py +++ b/iconSelector.py @@ -8,7 +8,8 @@ windWords = ["wind", "windy", "gusts"] def parseDescription(desc): # Parse a weather description by returning the first # "weather word" in a NWS description. - parsed = desc.split(" ") + # parsed = ((desc.lower()).split("/")).split(" ") + parsed = ((desc.lower()).split(" ")) for i in parsed: if i in adjectives: @@ -30,14 +31,20 @@ def parseDescription(desc): def imageSelector(desc, timeOfDay): match desc: case "Clear": - return "./smallIcons/clear-day-small.png" + if timeOfDay == "day": + return "/smallIcons/clear-day-small.png" + else: + return "/smallIcons/clear-night-small.png" case "Cloudy": - return "./smallIcons/cloudy-small.png" + if timeOfDay == "day": + return "/smallIcons/overcast-day-small.png" + else: + return "/smallIcons/overcast-night-small.png" case "Wind": - return "./smallIcons/wind-small.png" + return "/smallIcons/wind-small.png" case "Thunderstorm": - return "./smallIcons/thunderstorms-day-small.png" + return "/smallIcons/thunderstorms-rain-small.png" case "Rain": - return "./smallIcons/rain-small.png" + return "/smallIcons/rain-small.png" - return "" + return "/smallIcons/code-red-small.png" diff --git a/readme.md b/readme.md index e9c1516..86b58bc 100644 --- a/readme.md +++ b/readme.md @@ -4,6 +4,9 @@ For use in XFCE for monitoring weather from a given station using the National W Instructions: - Download files -- Run weather.py from XFCE GenMon as path/to/script/weather.py -station STATIONNAME +- Run weather.py from XFCE GenMon as path/to/script/weather.py STATIONNAME Without a station name, the script will report the weather at Hartsfield-Jackson International Airport in Atlanta, GA. + +TODO: add zipcode as a proper arguement and find the nearest station for current observations. +- Five Day Forecast in tooltip. diff --git a/weather.py b/weather.py index 179a43c..3156078 100644 --- a/weather.py +++ b/weather.py @@ -1,6 +1,7 @@ import requests import math import sys +import iconSelector as iconSelect try: stationName = sys.argv[1] @@ -87,7 +88,9 @@ else: roundedTemp = rounding(temp) condition = request_json["properties"]["textDescription"] timeOfDay = request_json['properties']['icon'].split("/")[5] + weatherIcon = iconSelect.parseDescription(condition) + weatherIconImage = f"/home/nclanceman/tools/weather{iconSelect.imageSelector(weatherIcon, timeOfDay)}" # print(f" \u2601 {condition}, {roundedTemp} F") print( - f"/home/nclanceman/tools/weather/smallIcons/cloudy-small.png {condition}, {roundedTemp}F") + f"{weatherIconImage} {condition}, {roundedTemp}F") print(tooltipPrinter(request_json))