From 7ebc304970e8288a046403f7ef47dd245b7b51ea Mon Sep 17 00:00:00 2001 From: notgne2 Date: Tue, 5 Oct 2021 23:36:34 -0700 Subject: [PATCH] don't fill up screen space if wttr.in is down --- home-manager/modules/ezpcusr.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/home-manager/modules/ezpcusr.nix b/home-manager/modules/ezpcusr.nix index 96a9d24..7c9c399 100644 --- a/home-manager/modules/ezpcusr.nix +++ b/home-manager/modules/ezpcusr.nix @@ -372,7 +372,10 @@ in modules-center = [ "custom/left-arrow-dark" "clock#1" "clock#2" "custom/left-arrow-light" "custom/left-arrow-dark" "mpd" "custom/right-arrow-dark" "custom/right-arrow-light" "clock#3" "custom/right-arrow-dark" ]; modules-right = [ "custom/left-arrow-dark" "pulseaudio" "custom/left-arrow-light" "custom/left-arrow-dark" "memory" "custom/left-arrow-light" "custom/left-arrow-dark" "cpu" "custom/left-arrow-light" "custom/left-arrow-dark" ] ++ lib.optionals cfg.battery [ "battery" "custom/left-arrow-light" "custom/left-arrow-dark" ] ++ [ "tray" ]; - modules = { + modules = + let + checkWttr = "${pkgs.bash}/bin/bash -c '! (${pkgs.curl}/bin/curl wttr.in/${cfg.location}?format=+ | ${pkgs.gnugrep}/bin/grep \\'^Unknown location;\\')'"; + in { "custom/left-arrow-dark" = { format = ""; tooltip = false; @@ -395,18 +398,21 @@ in }; "custom/weather-temp" = { - exec = "${pkgs.curl}/bin/curl 'wttr.in/${cfg.location}?format=%c+%t'"; + exec-if = checkWttr; + exec = "${pkgs.curl}/bin/curl 'wttr.in/${cfg.location}?format=%c+%t' || echo ERR"; on-click = "${pkgs.xdg-utils}/bin/xdg-open 'https://weather.com/weather/today/l/85625'"; on-click-right = "${pkgs.xdg-utils}/bin/xdg-open 'https://wttr.in/${cfg.location}'"; interval = 900; }; "custom/weather-precip" = { + exec-if = checkWttr; exec = "${pkgs.curl}/bin/curl 'wttr.in/${cfg.location}?format=🌧️+%p'"; on-click = "${pkgs.xdg-utils}/bin/xdg-open 'https://www.lightningmaps.org/'"; on-click-right = "${pkgs.xdg-utils}/bin/xdg-open 'https://wttr.in/${cfg.location}'"; interval = 900; }; "custom/weather-wind" = { + exec-if = checkWttr; exec = "${pkgs.curl}/bin/curl 'wttr.in/${cfg.location}?format=🌬️+%w'"; on-click = "${pkgs.xdg-utils}/bin/xdg-open 'https://www.ventusky.com/"; on-click-right = "${pkgs.xdg-utils}/bin/xdg-open 'https://wttr.in/${cfg.location}'";