2 Commits

Author SHA1 Message Date
  Josh Fabean 3178fecbb0 adding weather widget 1 year ago
  Josh Fabean a36558061a sway update 1 year ago
3 changed files with 132 additions and 7 deletions
Split View
  1. +6
    -5
      .config/sway/articuno-sway
  2. +11
    -2
      .config/waybar/config
  3. +115
    -0
      waybar-wttr.py

+ 6
- 5
.config/sway/articuno-sway View File

@ -51,7 +51,7 @@ mode "app" {
bindsym --release $mod+space mode "default"
# Mnemonic: [b]rowser
bindsym b exec MOZ_ENABLE_WAYLAND=1 firefox-developer-edition
bindsym b exec MOZ_ENABLE_WAYLAND=1 waterfox-g4
# Mnemonic: [f]ile explorer
bindsym f exec 'io.elementary.files'
# Mnemonic: [F]ile explorer, GUI
@ -75,11 +75,11 @@ mode "app" {
# Mnemonix: tmu[x]
bindsym x exec $term -e bash -ci 'tmux-session'
#bindsym c exec code-insiders --enable-features=UseOzonePlatform --ozone-platform=wayland
bindsym c exec code-insiders
bindsym c exec vscodium --enable-features=UseOzonePlatform --ozone-platform=wayland
#bindsym c exec vscodium
#bindsym s exec slack --enable-features=UseOzonePlatform --ozone-platform=wayland
bindsym s exec slack
bindsym s exec slack --enable-features=UseOzonePlatform --ozone-platform=wayland
#bindsym s exec slack
bindsym d exec discord
bindsym t exec fluffychat
@ -251,6 +251,7 @@ for_window [class="^zoom$"] floating enable
for_window [app_id="zoom" title="Choose ONE of the audio conference options"] floating enable
for_window [app_id="zoom" title="zoom"] floating enable
for_window [app_id="zoom" title="Zoom Meeting"] floating disable
for_window [title="KJAX_loop.gif - mpv"] floating enable
# Tag xwayland windows with [X]
for_window [shell="xwayland"] title_format "<span>[X] %title゜</span>"


+ 11
- 2
.config/waybar/config View File

@ -20,6 +20,7 @@
"modules-right": [
"tray",
"custom/watson",
"custom/weather",
"custom/calc",
"pulseaudio",
// "network",
@ -37,7 +38,7 @@
},
"disk": {
"interval": 30,
"format": "{percentage_used}% <span></span>",
"format": "{percentage_used}% <span>💾</span>",
},
"sway/mode": {
"format": "<span style=\"italic\">{}</span>"
@ -192,7 +193,7 @@
"on-click": "playerctl -p tuijam play-pause"
},
"custom/watson": {
"format": "{} ",
"format": "{} ⏱️",
//"max-length": 15,
"interval": 10,
"exec": "watson-status",
@ -203,6 +204,14 @@
"interval": 1000,
"on-click": "qalculate-gtk"
},
"custom/weather": {
"format": "{}",
"tooltip": true,
"interval": 3600,
"exec": "waybar-wttr.py",
"return-type": "json",
"on-click": "mpv https://radar.weather.gov/ridge/lite/KJAX_loop.gif --loop-file=inf"
},
"custom/playerctl": {
"format": "{}",
"exec": ""


+ 115
- 0
waybar-wttr.py View File

@ -0,0 +1,115 @@
#!/usr/bin/env python
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("https://wttr.in/palm-coast?format=j1").json()
def format_time(time):
return time.replace("00", "").zfill(2)
def format_temp(temp):
return (hour['FeelsLikeF']+"°").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)
data['text'] = WEATHER_CODES[weather['current_condition'][0]['weatherCode']] + \
" "+weather['current_condition'][0]['FeelsLikeF']+"°"
data['tooltip'] = f"<b>{weather['current_condition'][0]['weatherDesc'][0]['value']} {weather['current_condition'][0]['temp_F']}°</b>\n"
data['tooltip'] += f"Feels like: {weather['current_condition'][0]['FeelsLikeF']}°\n"
data['tooltip'] += f"Wind: {weather['current_condition'][0]['windspeedMiles']}mph\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['maxtempF']}° ⬇️ {day['mintempF']}° "
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:
continue
data['tooltip'] += f"{format_time(hour['time'])} {WEATHER_CODES[hour['weatherCode']]} {format_temp(hour['FeelsLikeF'])} {hour['weatherDesc'][0]['value']}, {format_chances(hour)}\n"
print(json.dumps(data))

Loading…
Cancel
Save