Don't show weather errors

This commit is contained in:
notgne2 2022-11-06 15:43:29 -07:00
parent da7a0d3ec6
commit 742ce27e01
Signed by: notgne2
SSH Key Fingerprint: SHA256:qlFCAimT/PvNIG3u+aYT9pIqFCWgu6sNsWjpV1vHLIE

View File

@ -372,11 +372,14 @@ in {
target = lib.mkDefault "sway-session.target"; target = lib.mkDefault "sway-session.target";
}; };
settings.mainbar = { settings.mainbar = let
weatherCommand = f: "${pkgs.curl}/bin/curl 'wttr.in/${cfg.location}?format=${f}' || echo 'ERR'";
weatherIf = "(${pkgs.curl}/bin/curl 'wttr.in/${cfg.location}?format=%t' || echo 'ERR') | grep -c 'ERR|Unknown'";
in {
position = lib.mkDefault "left"; position = lib.mkDefault "left";
height = lib.mkDefault null; height = lib.mkDefault null;
modules-left = ["sway/workspaces" "custom/spacer" "custom/weather-temp" "custom/weather-precip" "custom/weather-wind"]; modules-left = ["sway/workspaces" "custom/weather-spacer" "custom/weather-temp" "custom/weather-precip" "custom/weather-wind"];
modules-center = ["clock#1" "clock#2" "custom/spacer" "custom/media" "custom/spacer" "clock#3" "custom/spacer" "clock#4"]; modules-center = ["clock#1" "clock#2" "custom/spacer" "custom/media" "custom/spacer" "clock#3" "custom/spacer" "clock#4"];
modules-right = ["pulseaudio" "custom/spacer" "memory" "custom/spacer" "cpu"] ++ lib.optionals cfg.battery ["custom/spacer" "battery"] ++ ["custom/spacer" "tray"]; modules-right = ["pulseaudio" "custom/spacer" "memory" "custom/spacer" "cpu"] ++ lib.optionals cfg.battery ["custom/spacer" "battery"] ++ ["custom/spacer" "tray"];
@ -386,20 +389,30 @@ in {
tooltip = lib.mkDefault false; tooltip = lib.mkDefault false;
}; };
"custom/weather-spacer" = {
exec-if = weatherIf;
format = lib.mkDefault "";
rotate = lib.mkDefault 90;
tooltip = lib.mkDefault false;
};
"custom/weather-temp" = { "custom/weather-temp" = {
exec = lib.mkDefault "${pkgs.curl}/bin/curl 'wttr.in/${cfg.location}?format=%c+%t' || echo ERR"; exec = lib.mkDefault (weatherCommand "%t+%c");
exec-if = weatherIf;
on-click = lib.mkDefault "${pkgs.xdg-utils}/bin/xdg-open 'https://weather.com/weather/today/l/85625'"; on-click = lib.mkDefault "${pkgs.xdg-utils}/bin/xdg-open 'https://weather.com/weather/today/l/85625'";
on-click-right = lib.mkDefault "${pkgs.xdg-utils}/bin/xdg-open 'https://wttr.in/${cfg.location}'"; on-click-right = lib.mkDefault "${pkgs.xdg-utils}/bin/xdg-open 'https://wttr.in/${cfg.location}'";
interval = lib.mkDefault 900; interval = lib.mkDefault 900;
}; };
"custom/weather-precip" = { "custom/weather-precip" = {
exec = lib.mkDefault "${pkgs.curl}/bin/curl 'wttr.in/${cfg.location}?format=🌧+%p'"; exec = lib.mkDefault (weatherCommand "🌧+%p");
exec-if = weatherIf;
on-click = lib.mkDefault "${pkgs.xdg-utils}/bin/xdg-open 'https://www.lightningmaps.org/'"; on-click = lib.mkDefault "${pkgs.xdg-utils}/bin/xdg-open 'https://www.lightningmaps.org/'";
on-click-right = "lib.mkDefault ${pkgs.xdg-utils}/bin/xdg-open 'https://wttr.in/${cfg.location}'"; on-click-right = "lib.mkDefault ${pkgs.xdg-utils}/bin/xdg-open 'https://wttr.in/${cfg.location}'";
interval = lib.mkDefault 900; interval = lib.mkDefault 900;
}; };
"custom/weather-wind" = { "custom/weather-wind" = {
exec = lib.mkDefault "${pkgs.curl}/bin/curl 'wttr.in/${cfg.location}?format=🌬+%w'"; exec = lib.mkDefault (weatherCommand "🌬+%w");
exec-if = weatherIf;
on-click = lib.mkDefault "${pkgs.xdg-utils}/bin/xdg-open 'https://www.ventusky.com/"; on-click = lib.mkDefault "${pkgs.xdg-utils}/bin/xdg-open 'https://www.ventusky.com/";
on-click-right = lib.mkDefault "${pkgs.xdg-utils}/bin/xdg-open 'https://wttr.in/${cfg.location}'"; on-click-right = lib.mkDefault "${pkgs.xdg-utils}/bin/xdg-open 'https://wttr.in/${cfg.location}'";
interval = lib.mkDefault 900; interval = lib.mkDefault 900;