aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/scripts/Weather.py
diff options
context:
space:
mode:
authorJa.KooLit <jimmielovejay@gmail.com>2023-12-29 15:44:57 +0900
committerGitHub <noreply@github.com>2023-12-29 15:44:57 +0900
commit2c070b5bfb2de84abed8a4cd45e999999021db38 (patch)
treeab297f40d72eab1dad7506e005cec1654f942ff6 /config/hypr/scripts/Weather.py
parent76672ae5a6ac03c416bc705d51dec363f88b7a40 (diff)
parent69772de8b00a85a7da8e3d56c802fcfd01affe1c (diff)
Merge pull request #106 from JaKooLit/development
Development to Main for v2.2.2 Changes
Diffstat (limited to 'config/hypr/scripts/Weather.py')
-rwxr-xr-xconfig/hypr/scripts/Weather.py122
1 files changed, 0 insertions, 122 deletions
diff --git a/config/hypr/scripts/Weather.py b/config/hypr/scripts/Weather.py
deleted file mode 100755
index 154c1589..00000000
--- a/config/hypr/scripts/Weather.py
+++ /dev/null
@@ -1,122 +0,0 @@
-#!/usr/bin/env python3
-# From https://raw.githubusercontent.com/rxyhn/dotfiles/main/home/rxyhn/modules/desktop/waybar/scripts/waybar-wttr.py
-
-## ensure to insert city inside ""
-city = ""
-import json
-import requests
-from datetime import datetime
-
-WEATHER_CODES = {
- '113': '',
- '116': '󰖕',
- '119': '',
- '122': '',
- '143': '',
- '176': '',
- '179': '',
- '182': '',
- '185': '',
- '200': '⛈️',
- '227': '🌨️',
- '230': '🌨️',
- '248': '☁️ ',
- '260': '☁️',
- '263': '🌧️',
- '266': '🌧️',
- '281': '🌧️',
- '284': '🌧️',
- '293': '🌧️',
- '296': '🌧️',
- '299': '🌧️',
- '302': '🌧️',
- '305': '🌧️',
- '308': '🌧️',
- '311': '🌧️',
- '314': '🌧️',
- '317': '🌧️',
- '320': '🌨️',
- '323': '🌨️',
- '326': '🌨️',
- '329': '❄️',
- '332': '❄️',
- '335': '❄️',
- '338': '❄️',
- '350': '🌧️',
- '353': '🌧️',
- '356': '🌧️',
- '359': '🌧️',
- '362': '🌧️',
- '365': '🌧️',
- '368': '🌧️',
- '371': '❄️',
- '374': '🌨️',
- '377': '🌨️',
- '386': '🌨️',
- '389': '🌨️',
- '392': '🌧️',
- '395': '❄️'
-}
-
-data = {}
-
-
-weather = requests.get(f"https://wttr.in/{city}?format=j1").json()
-
-
-def format_time(time):
- return time.replace("00", "").zfill(2)
-
-
-def format_temp(temp):
- return (hour['FeelsLikeC']+"°").ljust(3)
-
-
-def format_chances(hour):
- chances = {
- "chanceoffog": "Fog",
- "chanceoffrost": "Frost",
- "chanceofovercast": "Overcast",
- "chanceofrain": "Rain",
- "chanceofsnow": "Snow",
- "chanceofsunshine": "Sunshine",
- "chanceofthunder": "Thunder",
- "chanceofwindy": "Wind"
- }
-
- conditions = []
- for event in chances.keys():
- if int(hour[event]) > 0:
- conditions.append(chances[event]+" "+hour[event]+"%")
- return ", ".join(conditions)
-
-tempint = int(weather['current_condition'][0]['FeelsLikeC'])
-extrachar = ''
-if tempint > 0 and tempint < 10:
- extrachar = '+'
-
-
-data['text'] = ' '+WEATHER_CODES[weather['current_condition'][0]['weatherCode']] + \
- " "+extrachar+weather['current_condition'][0]['FeelsLikeC']+"°"
-
-data['tooltip'] = f"<b>{weather['current_condition'][0]['weatherDesc'][0]['value']} {weather['current_condition'][0]['temp_C']}°</b>\n"
-data['tooltip'] += f"Feels like: {weather['current_condition'][0]['FeelsLikeC']}°\n"
-data['tooltip'] += f"Wind: {weather['current_condition'][0]['windspeedKmph']}Km/h\n"
-data['tooltip'] += f"Humidity: {weather['current_condition'][0]['humidity']}%\n"
-for i, day in enumerate(weather['weather']):
- data['tooltip'] += f"\n<b>"
- if i == 0:
- data['tooltip'] += "Today, "
- if i == 1:
- data['tooltip'] += "Tomorrow, "
- data['tooltip'] += f"{day['date']}</b>\n"
- data['tooltip'] += f"⬆️{day['maxtempC']}° ⬇️{day['mintempC']}° "
- data['tooltip'] += f"🌅{day['astronomy'][0]['sunrise']} 🌇{day['astronomy'][0]['sunset']}\n"
- for hour in day['hourly']:
- if i == 0:
- if int(format_time(hour['time'])) < datetime.now().hour-2:
- continue
- data['tooltip'] += f"{format_time(hour['time'])} {WEATHER_CODES[hour['weatherCode']]} {format_temp(hour['FeelsLikeC'])} {hour['weatherDesc'][0]['value']}, {format_chances(hour)}\n"
-
-
-print(json.dumps(data))
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage