mirror of
https://github.com/kmein/niveum
synced 2026-03-19 03:21:10 +01:00
feat(i3status-rust): rewrite sun timer to work offline
This commit is contained in:
@@ -95,11 +95,15 @@ in {
|
|||||||
{
|
{
|
||||||
block = "custom";
|
block = "custom";
|
||||||
interval = 60 * 60;
|
interval = 60 * 60;
|
||||||
command = let inherit (import <niveum/configs/spacetime.nix>) location; in pkgs.writers.writeDash "sun-times" ''
|
command = let spacetime = import <niveum/configs/spacetime.nix>; in pkgs.writers.writePython3 "sun.py" { libraries = [ pkgs.python3Packages.astral ]; flakeIgnore = [ "E501" ]; }
|
||||||
result="$(${pkgs.curl}/bin/curl -sSL "https://api.sunrise-sunset.org/json?formatted=0&lat=${toString location.latitude}&lng=${toString location.longitude}")"
|
''
|
||||||
sunrise="$(echo "$result" | ${pkgs.jq}/bin/jq -r .results.sunrise)"
|
import astral
|
||||||
sunset="$(echo "$result" | ${pkgs.jq}/bin/jq -r .results.sunset)"
|
import astral.sun
|
||||||
echo "🌅 $(${pkgs.coreutils}/bin/date +%R -d "$sunrise") 🌇 $(${pkgs.coreutils}/bin/date +%R -d "$sunset")"
|
|
||||||
|
city = astral.LocationInfo("Berlin", "Germany", "${spacetime.time.timeZone}", ${toString spacetime.location.latitude}, ${toString spacetime.location.longitude})
|
||||||
|
sun = astral.sun.sun(city.observer, date=astral.today(), tzinfo=city.timezone)
|
||||||
|
|
||||||
|
print("🌅 {} 🌇 {}".format(sun["sunrise"].strftime("%R"), sun["sunset"].strftime("%R")))
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user