Don't show weather errors
This commit is contained in:
parent
da7a0d3ec6
commit
742ce27e01
@ -372,11 +372,14 @@ in {
|
||||
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";
|
||||
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-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;
|
||||
};
|
||||
|
||||
"custom/weather-spacer" = {
|
||||
exec-if = weatherIf;
|
||||
format = lib.mkDefault "〜";
|
||||
rotate = lib.mkDefault 90;
|
||||
tooltip = lib.mkDefault false;
|
||||
};
|
||||
|
||||
"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-right = lib.mkDefault "${pkgs.xdg-utils}/bin/xdg-open 'https://wttr.in/${cfg.location}'";
|
||||
interval = lib.mkDefault 900;
|
||||
};
|
||||
"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-right = "lib.mkDefault ${pkgs.xdg-utils}/bin/xdg-open 'https://wttr.in/${cfg.location}'";
|
||||
interval = lib.mkDefault 900;
|
||||
};
|
||||
"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-right = lib.mkDefault "${pkgs.xdg-utils}/bin/xdg-open 'https://wttr.in/${cfg.location}'";
|
||||
interval = lib.mkDefault 900;
|
||||
|
Loading…
Reference in New Issue
Block a user