📦️ deps(waybar): use wttrbar instead of custom script

more efficient and the script was not working correctly
This commit is contained in:
Sergio Laín 2024-03-22 21:36:05 +01:00
parent c8cf1999e5
commit d199098e19
No known key found for this signature in database
GPG key ID: 14C9B8080681777B
3 changed files with 52 additions and 175 deletions

View file

@ -15,7 +15,7 @@
"custom/arch", "custom/arch",
"hyprland/workspaces", "hyprland/workspaces",
"cava", "cava",
"custom/wf-recorder" "custom/wf-recorder",
], ],
"modules-center": ["custom/music"], "modules-center": ["custom/music"],
"modules-right": [ "modules-right": [
@ -24,7 +24,7 @@
"custom/weather", "custom/weather",
"clock", "clock",
"pulseaudio", "pulseaudio",
"custom/notifications" "custom/notifications",
], ],
"custom/wf-recorder": { "custom/wf-recorder": {
"format": "{}", "format": "{}",
@ -33,33 +33,35 @@
"tooltip": "false", "tooltip": "false",
"exec-if": "pgrep 'wf-recorder'", "exec-if": "pgrep 'wf-recorder'",
"on-click": "exec $HOME/.config/hypr/scripts/rofi/recording", "on-click": "exec $HOME/.config/hypr/scripts/rofi/recording",
"signal": 8 "signal": 8,
}, },
"custom/updates": { "custom/updates": {
"format": "{} {icon}", "format": "{} {icon}",
"return-type": "json", "return-type": "json",
"format-icons": { "format-icons": {
"has-updates": "󱍷", "has-updates": "󱍷",
"updated": "󰂪" "updated": "󰂪",
}, },
"exec-if": "which waybar-module-pacman-updates", "exec-if": "which waybar-module-pacman-updates",
"exec": "waybar-module-pacman-updates", "exec": "waybar-module-pacman-updates",
"on-click": "kitty --class center-float-large topgrade -k --only system", "on-click": "kitty --class center-float-large topgrade -k --only system",
"on-click-right": "kitty --class center-float-large topgrade -k --no-self-update" "on-click-right": "kitty --class center-float-large topgrade -k --no-self-update",
}, },
"custom/arch": { "custom/arch": {
"format": "  ", "format": "  ",
"tooltip": false, "tooltip": false,
"on-click": "sleep 0.1 && rofi -show drun", "on-click": "sleep 0.1 && rofi -show drun",
"on-click-right": "wleave" "on-click-right": "wleave",
}, },
"custom/weather": { "custom/weather": {
"exec": "python3 ~/.config/waybar/scripts/weather.py", "exec": "wttrbar --location Alicante",
"restart-interval": 300, "restart-interval": 300,
"tooltip": true,
"format": "{}°",
"return-type": "json", "return-type": "json",
"on-click": "kitty --hold --class center-float wttr Alicante", "on-click": "kitty --hold --class center-float wttr Alicante",
"on-click-right": "kitty --hold --class center-float wttr -v2 Alicante", "on-click-right": "kitty --hold --class center-float wttr -v2 Alicante",
"on-click-middle": "xdg-open https://www.eltiempo.es/alicante.html" "on-click-middle": "xdg-open https://wttr.in/alicante",
}, },
"custom/notifications": { "custom/notifications": {
"tooltip": false, "tooltip": false,
@ -72,14 +74,14 @@
"inhibited-notification": "<span foreground='red'><sup></sup></span>", "inhibited-notification": "<span foreground='red'><sup></sup></span>",
"inhibited-none": "", "inhibited-none": "",
"dnd-inhibited-notification": "<span foreground='red'><sup></sup></span>", "dnd-inhibited-notification": "<span foreground='red'><sup></sup></span>",
"dnd-inhibited-none": "" "dnd-inhibited-none": "",
}, },
"return-type": "json", "return-type": "json",
"exec-if": "which swaync-client", "exec-if": "which swaync-client",
"exec": "swaync-client -swb", "exec": "swaync-client -swb",
"on-click": "sleep 0.1 && swaync-client -t -sw", "on-click": "sleep 0.1 && swaync-client -t -sw",
"on-click-right": "swaync-client -d -sw", "on-click-right": "swaync-client -d -sw",
"escape": true "escape": true,
}, },
"hyprland/workspaces": { "hyprland/workspaces": {
"disable-scroll": true, "disable-scroll": true,
@ -96,18 +98,18 @@
"7": "", "7": "",
"8": "", "8": "",
"9": "", "9": "",
"10": "" "10": "",
}, },
"on-scroll-up": "hyprctl dispatch workspace r-1", "on-scroll-up": "hyprctl dispatch workspace r-1",
"on-scroll-down": "hyprctl dispatch workspace r+1", "on-scroll-down": "hyprctl dispatch workspace r+1",
"on-click": "activate", "on-click": "activate",
"sort-by-number": true "sort-by-number": true,
}, },
"hyprland/language": { "hyprland/language": {
"format": "{}", "format": "{}",
"format-en": " US", "format-en": " US",
"format-es": " ES", "format-es": " ES",
"on-click": "hyprctl switchxkblayout evision-usb-device next" "on-click": "hyprctl switchxkblayout evision-usb-device next",
}, },
"clock": { "clock": {
"tooltip-format": "<tt><small>{calendar}</small></tt>", "tooltip-format": "<tt><small>{calendar}</small></tt>",
@ -122,8 +124,8 @@
"days": "<span color='#cad3f5'><b>{}</b></span>", "days": "<span color='#cad3f5'><b>{}</b></span>",
"weeks": "<span color='#8aadf4'><b>W{}</b></span>", "weeks": "<span color='#8aadf4'><b>W{}</b></span>",
"weekdays": "<span color='#8bd5ca'><b>{}</b></span>", "weekdays": "<span color='#8bd5ca'><b>{}</b></span>",
"today": "<span color='#ed8796'><b><u>{}</u></b></span>" "today": "<span color='#ed8796'><b><u>{}</u></b></span>",
} },
}, },
"interval": 1, "interval": 1,
"format": "{:%H:%M:%OS}  ", "format": "{:%H:%M:%OS}  ",
@ -133,9 +135,9 @@
"on-click-forward": "tz_up", "on-click-forward": "tz_up",
"on-click-backward": "tz_down", "on-click-backward": "tz_down",
"on-scroll-up": "shift_up", "on-scroll-up": "shift_up",
"on-scroll-down": "shift_down" "on-scroll-down": "shift_down",
}, },
"on-click-middle": "thunderbird -calendar && hyprctl dispatch workspace 23" "on-click-middle": "thunderbird -calendar && hyprctl dispatch workspace 23",
}, },
"pulseaudio": { "pulseaudio": {
"format": "{icon} {volume}% {format_source}", "format": "{icon} {volume}% {format_source}",
@ -151,14 +153,14 @@
"phone": " ", "phone": " ",
"portable": " ", "portable": " ",
"car": " ", "car": " ",
"default": [" ", " ", " "] "default": [" ", " ", " "],
}, },
"tooltip-format": "{desc}, {volume}%", "tooltip-format": "{desc}, {volume}%",
"on-click": "swayosd-client --output-volume mute-toggle", "on-click": "swayosd-client --output-volume mute-toggle",
"on-click-right": "swayosd-client --input-volume mute-toggle", "on-click-right": "swayosd-client --input-volume mute-toggle",
"on-click-middle": "pypr toggle volume", "on-click-middle": "pypr toggle volume",
"on-scroll-up": "swayosd-client --output-volume +1", "on-scroll-up": "swayosd-client --output-volume +1",
"on-scroll-down": "swayosd-client --output-volume -1" "on-scroll-down": "swayosd-client --output-volume -1",
}, },
"cava": { "cava": {
"autosens": 1, "autosens": 1,
@ -172,7 +174,7 @@
"<span foreground='#89b4fa'>▅</span>", "<span foreground='#89b4fa'>▅</span>",
"<span foreground='#89b4fa'>▆</span>", "<span foreground='#89b4fa'>▆</span>",
"<span foreground='#89b4fa'>▇</span>", "<span foreground='#89b4fa'>▇</span>",
"<span foreground='#89b4fa'>█</span>" "<span foreground='#89b4fa'>█</span>",
], ],
"framerate": 75, "framerate": 75,
"higher_cutoff_freq": 10000, "higher_cutoff_freq": 10000,
@ -186,7 +188,7 @@
"waves": false, "waves": false,
"on-click": "kitty --class center-float-mini cava", "on-click": "kitty --class center-float-mini cava",
"on-click-right": "qpwgraph", "on-click-right": "qpwgraph",
"on-click-middle": "easyeffects" "on-click-middle": "easyeffects",
}, },
"custom/music": { "custom/music": {
"format": "{icon} {}", "format": "{icon} {}",
@ -194,14 +196,14 @@
"max-length": 100, "max-length": 100,
"format-icons": { "format-icons": {
"spotify": " ", "spotify": " ",
"default": " " "default": " ",
}, },
"escape": true, "escape": true,
"exec": "$HOME/.config/waybar/scripts/mediaplayer.py 2> /dev/null", "exec": "$HOME/.config/waybar/scripts/mediaplayer.py 2> /dev/null",
"on-click": "playerctl --player=spotify play-pause", "on-click": "playerctl --player=spotify play-pause",
"on-scroll-up": "playerctl --player=spotify next", "on-scroll-up": "playerctl --player=spotify next",
"on-scroll-down": "playerctl --player=spotify previous" "on-scroll-down": "playerctl --player=spotify previous",
} },
}, },
{ {
"height": 50, "height": 50,
@ -222,7 +224,7 @@
"temperature#cpu", "temperature#cpu",
"custom/gpu-usage", "custom/gpu-usage",
"temperature#gpu", "temperature#gpu",
"custom/notifications" "custom/notifications",
], ],
"hyprland/window": { "hyprland/window": {
"format": "{}", "format": "{}",
@ -230,15 +232,15 @@
"rewrite": { "rewrite": {
"(.*) — LibreWolf": "󰇧 $1", "(.*) — LibreWolf": "󰇧 $1",
"(.*) - Discord": "󰙯 $1", "(.*) - Discord": "󰙯 $1",
"(.*) - fish": "> [$1]" "(.*) - fish": "> [$1]",
}, },
"separate-outputs": false "separate-outputs": false,
}, },
"custom/arch": { "custom/arch": {
"format": "  ", "format": "  ",
"tooltip": false, "tooltip": false,
"on-click": "sleep 0.1 && rofi -show drun", "on-click": "sleep 0.1 && rofi -show drun",
"on-click-right": "wleave" "on-click-right": "wleave",
}, },
"custom/notifications": { "custom/notifications": {
"tooltip": false, "tooltip": false,
@ -251,14 +253,14 @@
"inhibited-notification": "<span foreground='red'><sup></sup></span>", "inhibited-notification": "<span foreground='red'><sup></sup></span>",
"inhibited-none": "", "inhibited-none": "",
"dnd-inhibited-notification": "<span foreground='red'><sup></sup></span>", "dnd-inhibited-notification": "<span foreground='red'><sup></sup></span>",
"dnd-inhibited-none": "" "dnd-inhibited-none": "",
}, },
"return-type": "json", "return-type": "json",
"exec-if": "which swaync-client", "exec-if": "which swaync-client",
"exec": "swaync-client -swb", "exec": "swaync-client -swb",
"on-click": "sleep 0.1 && swaync-client -t -sw", "on-click": "sleep 0.1 && swaync-client -t -sw",
"on-click-right": "swaync-client -d -sw", "on-click-right": "swaync-client -d -sw",
"escape": true "escape": true,
}, },
"hyprland/workspaces": { "hyprland/workspaces": {
"disable-scroll": true, "disable-scroll": true,
@ -276,31 +278,31 @@
"17": "", "17": "",
"18": "", "18": "",
"19": "", "19": "",
"20": "" "20": "",
}, },
"on-scroll-up": "hyprctl dispatch workspace r-1", "on-scroll-up": "hyprctl dispatch workspace r-1",
"on-scroll-down": "hyprctl dispatch workspace r+1", "on-scroll-down": "hyprctl dispatch workspace r+1",
"on-click": "activate", "on-click": "activate",
"sort-by-number": true "sort-by-number": true,
}, },
"cpu": { "cpu": {
"on-click": "kitty --class center-float-large btop", "on-click": "kitty --class center-float-large btop",
"format": "CPU: {usage}%", "format": "CPU: {usage}%",
"tooltip": false, "tooltip": false,
"interval": 2 "interval": 2,
}, },
"custom/gpu-usage": { "custom/gpu-usage": {
"exec": "cat /sys/class/hwmon/hwmon1/device/gpu_busy_percent", "exec": "cat /sys/class/hwmon/hwmon1/device/gpu_busy_percent",
"on-click": "kitty --class center-float-large nvtop", "on-click": "kitty --class center-float-large nvtop",
"format": "GPU: {}%", "format": "GPU: {}%",
"return-type": "", "return-type": "",
"interval": 2 "interval": 2,
}, },
"memory": { "memory": {
"format": "{}%  ", "format": "{}%  ",
"on-click": "kitty --class center-float-large btop", "on-click": "kitty --class center-float-large btop",
"tooltip": true, "tooltip": true,
"interval": 2 "interval": 2,
}, },
"temperature#cpu": { "temperature#cpu": {
"critical-threshold": 90, "critical-threshold": 90,
@ -310,7 +312,7 @@
"format": "{icon} {temperatureC}°C", "format": "{icon} {temperatureC}°C",
"format-icons": ["", "", ""], "format-icons": ["", "", ""],
"tooltip": true, "tooltip": true,
"interval": 2 "interval": 2,
}, },
"temperature#gpu": { "temperature#gpu": {
"critical-threshold": 80, "critical-threshold": 80,
@ -320,8 +322,8 @@
"format": "{icon} {temperatureC}°C", "format": "{icon} {temperatureC}°C",
"format-icons": ["", "", ""], "format-icons": ["", "", ""],
"tooltip": true, "tooltip": true,
"interval": 2 "interval": 2,
} },
}, },
{ {
"height": 50, "height": 50,
@ -341,7 +343,7 @@
"format": "  ", "format": "  ",
"tooltip": false, "tooltip": false,
"on-click": "sleep 0.1 && rofi -show drun", "on-click": "sleep 0.1 && rofi -show drun",
"on-click-right": "wleave" "on-click-right": "wleave",
}, },
"custom/notifications": { "custom/notifications": {
"tooltip": false, "tooltip": false,
@ -354,14 +356,14 @@
"inhibited-notification": "<span foreground='red'><sup></sup></span>", "inhibited-notification": "<span foreground='red'><sup></sup></span>",
"inhibited-none": "", "inhibited-none": "",
"dnd-inhibited-notification": "<span foreground='red'><sup></sup></span>", "dnd-inhibited-notification": "<span foreground='red'><sup></sup></span>",
"dnd-inhibited-none": "" "dnd-inhibited-none": "",
}, },
"return-type": "json", "return-type": "json",
"exec-if": "which swaync-client", "exec-if": "which swaync-client",
"exec": "swaync-client -swb", "exec": "swaync-client -swb",
"on-click": "sleep 0.1 && swaync-client -t -sw", "on-click": "sleep 0.1 && swaync-client -t -sw",
"on-click-right": "swaync-client -d -sw", "on-click-right": "swaync-client -d -sw",
"escape": true "escape": true,
}, },
"hyprland/workspaces": { "hyprland/workspaces": {
"disable-scroll": true, "disable-scroll": true,
@ -378,15 +380,15 @@
"27": "", "27": "",
"28": "", "28": "",
"29": "", "29": "",
"30": "" "30": "",
}, },
"on-scroll-up": "hyprctl dispatch workspace r-1", "on-scroll-up": "hyprctl dispatch workspace r-1",
"on-scroll-down": "hyprctl dispatch workspace r+1", "on-scroll-down": "hyprctl dispatch workspace r+1",
"on-click": "activate", "on-click": "activate",
"sort-by-number": true "sort-by-number": true,
}, },
"tray": { "tray": {
"spacing": 10 "spacing": 10,
}, },
"clock#cl2": { "clock#cl2": {
"tooltip-format": "<tt><small>{calendar}</small></tt>", "tooltip-format": "<tt><small>{calendar}</small></tt>",
@ -401,8 +403,8 @@
"days": "<span color='#cad3f5'><b>{}</b></span>", "days": "<span color='#cad3f5'><b>{}</b></span>",
"weeks": "<span color='#8aadf4'><b>W{}</b></span>", "weeks": "<span color='#8aadf4'><b>W{}</b></span>",
"weekdays": "<span color='#8bd5ca'><b>{}</b></span>", "weekdays": "<span color='#8bd5ca'><b>{}</b></span>",
"today": "<span color='#ed8796'><b><u>{}</u></b></span>" "today": "<span color='#ed8796'><b><u>{}</u></b></span>",
} },
}, },
"format": "{:%H:%M  - %A, %B %d, %Y  }", "format": "{:%H:%M  - %A, %B %d, %Y  }",
"actions": { "actions": {
@ -410,9 +412,9 @@
"on-click-forward": "tz_up", "on-click-forward": "tz_up",
"on-click-backward": "tz_down", "on-click-backward": "tz_down",
"on-scroll-up": "shift_up", "on-scroll-up": "shift_up",
"on-scroll-down": "shift_down" "on-scroll-down": "shift_down",
},
"on-click-middle": "thunderbird -calendar && hyprctl dispatch workspace 23",
},
}, },
"on-click-middle": "thunderbird -calendar && hyprctl dispatch workspace 23"
}
}
] ]

View file

@ -1,125 +0,0 @@
#!/usr/bin/env python
import json
from datetime import datetime
import requests
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/Alicante?format=j1").json()
def format_time(time):
return time.replace("00", "").zfill(2)
def format_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)
data["text"] = (
WEATHER_CODES[weather["current_condition"][0]["weatherCode"]]
+ " "
+ weather["current_condition"][0]["temp_C"]
+ "°C"
)
data[
"tooltip"
] = f"<b>{weather['current_condition'][0]['weatherDesc'][0]['value']} {weather['current_condition'][0]['temp_C']}°C</b>\n"
data["tooltip"] += f"Feels like: {weather['current_condition'][0]['FeelsLikeC']}°C\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))

BIN
.local/bin/wttrbar Executable file

Binary file not shown.