From 3eb2c829cd0181188d5325171c8232f3caf2c277 Mon Sep 17 00:00:00 2001 From: ulve Date: Fri, 19 Jun 2026 10:29:09 +0200 Subject: [PATCH] add weather widget to waybar --- config/waybar/niri-config | 9 ++++++++- config/waybar/style.css | 5 +++++ config/waybar/weather.sh | 7 +++++++ home.nix | 4 ++++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100755 config/waybar/weather.sh diff --git a/config/waybar/niri-config b/config/waybar/niri-config index dfcb502..78b4c4a 100644 --- a/config/waybar/niri-config +++ b/config/waybar/niri-config @@ -11,7 +11,7 @@ "tooltip": false }, "modules-center": ["clock"], - "modules-right": ["custom/network", "cpu", "battery"], + "modules-right": ["custom/weather", "custom/network", "cpu", "battery"], "niri/workspaces": { "disable-scroll": true @@ -22,6 +22,13 @@ "interval": 60 }, + "custom/weather": { + "exec": "~/.local/bin/waybar-weather.sh", + "interval": 1800, + "format": "{}", + "tooltip": false + }, + "custom/network": { "exec": "~/.local/bin/waybar-network.sh", "interval": 2, diff --git a/config/waybar/style.css b/config/waybar/style.css index d9085cb..bec03f8 100644 --- a/config/waybar/style.css +++ b/config/waybar/style.css @@ -41,6 +41,11 @@ window#waybar { color: #f3eeea; } +#custom-weather { + color: #f3eeea; + padding: 0 8px; +} + #custom-network { color: #f3eeea; padding: 0 8px; diff --git a/config/waybar/weather.sh b/config/waybar/weather.sh new file mode 100755 index 0000000..c95ee12 --- /dev/null +++ b/config/waybar/weather.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +result=$(curl -sf --max-time 10 "wttr.in/?format=%c+%t") +if [ $? -eq 0 ] && [ -n "$result" ]; then + echo "$result" +else + echo "N/A" +fi diff --git a/home.nix b/home.nix index fbc7c42..0e47452 100644 --- a/home.nix +++ b/home.nix @@ -259,6 +259,10 @@ source = ./config/waybar/network.sh; executable = true; }; + home.file.".local/bin/waybar-weather.sh" = { + source = ./config/waybar/weather.sh; + executable = true; + }; xdg.configFile."waybar".source = ./config/waybar; xdg.configFile."foot".source = ./config/foot; xdg.dataFile."applications/switch-wallpaper.desktop".source = ./config/applications/switch-wallpaper.desktop;