From 72f438bdae719ef9d598fff60dfe16815aa1e8dd Mon Sep 17 00:00:00 2001 From: reidlab Date: Wed, 1 Jan 2025 19:49:21 -0600 Subject: [PATCH] time zone and weather is now location based!! --- default.nix | 27 +++++++++++++++++----- hosts/goopnet-interface/default.nix | 4 ++-- modules/desktop/gammastep.nix | 5 +---- modules/desktop/waybar.nix | 35 +++++++++++++++++++++++++---- 4 files changed, 55 insertions(+), 16 deletions(-) diff --git a/default.nix b/default.nix index 750f919..b08fc78 100755 --- a/default.nix +++ b/default.nix @@ -50,28 +50,43 @@ in { }; }; - system.stateVersion = mkDefault "23.11"; + system.stateVersion = "23.11"; system.configurationRevision = with inputs; mkIf (self ? rev) self.rev; hm.home.stateVersion = config.system.stateVersion; boot = { kernelPackages = mkDefault pkgs.linuxPackages_latest; - kernelParams = ["pci_aspm.policy=performance"]; + kernelParams = [ "pci_aspm.policy=performance" ]; }; # configure keymap in x11 services.xserver.xkb = { layout = "us"; - # i need to learn this sometime - # variant = "workman"; + variant = "qwerty"; }; console = { useXkbConfig = mkDefault true; }; - time.timeZone = mkDefault "America/Los_Angeles"; + # set the time zone + services.automatic-timezoned.enable = mkDefault true; + time.timeZone = mkDefault null; # handled by automatic-timezoned - i18n.defaultLocale = mkDefault "en_US.UTF-8"; + i18n = mkDefault { + defaultLocale = "en_US.UTF-8"; + supportedLocales = [ "en_US.UTF-8/UTF-8" ]; + }; + + # set the location + location.provider = mkDefault "geoclue2"; + services.geoclue2 = { + enable = mkDefault true; + + # the default provider is Geeked + geoProviderUrl = "https://beacondb.net/v1/geolocate"; + submissionUrl = "https://beacondb.net/v2/geosubmit"; + submissionNick = "geoclue"; + }; hardware.enableRedistributableFirmware = true; diff --git a/hosts/goopnet-interface/default.nix b/hosts/goopnet-interface/default.nix index d84224c..268be26 100755 --- a/hosts/goopnet-interface/default.nix +++ b/hosts/goopnet-interface/default.nix @@ -21,14 +21,14 @@ # compatibility wineWowPackages.waylandFull winetricks # misc - bat file which packwiz yt-dlp fastfetch hyfetch + bat file which packwiz yt-dlp fastfetch hyfetch trashy # games prismlauncher ] ++ (with pkgs.my; [ # none yet ]) ++ (with pkgs.gnome; [ # yay gnomeware!!!!!!!!!!!!!! yum - nautilus gnome-disk-utility ghex pkgs.gnome-text-editor pkgs.baobab file-roller gnome-system-monitor loupe + nautilus gnome-disk-utility ghex pkgs.gnome-text-editor pkgs.baobab file-roller gnome-system-monitor loupe pkgs.gnome-weather ]); modules = { diff --git a/modules/desktop/gammastep.nix b/modules/desktop/gammastep.nix index 01b800e..498099b 100644 --- a/modules/desktop/gammastep.nix +++ b/modules/desktop/gammastep.nix @@ -13,10 +13,7 @@ in { enable = true; tray = true; - # portland, oregon - latitude = 45.3112; - longitude = -122.4055; - provider = "manual"; + provider = "geoclue2"; }; }; } diff --git a/modules/desktop/waybar.nix b/modules/desktop/waybar.nix index d79af56..0eabe20 100644 --- a/modules/desktop/waybar.nix +++ b/modules/desktop/waybar.nix @@ -75,7 +75,7 @@ in { ]; }; "custom/power" = let - powerSelect = pkgs.writeShellScript "power-menu" '' + powerMenuScript = pkgs.writeShellScript "power-menu" '' cmd=$(echo '⏻ shutdown|↻ reboot| lock|⎋ exit desktop environment' | ${lib.getExe pkgs.rofi-wayland} -dmenu -sep '|' -i -p 'what to do ?' -theme-str 'window { height: 132px; }') case "$cmd" in "⏻ shutdown") @@ -96,7 +96,7 @@ in { format = "⏻"; tooltip = true; tooltip-format = "Power menu"; - on-click = "${powerSelect}"; + on-click = "${powerMenuScript}"; }; "custom/wallpaper" = { format = ""; @@ -258,12 +258,39 @@ in { icon-size = 16; spacing = 4; }; - "custom/weather" = { + "custom/weather" = let + # this *should* be from coordinates, but we have to make it city because... + # https://github.com/chubin/wttr.in/issues/795 + # i was NOT going to let ip-based location be a thing. i was suprisingly medicated when i wrote this + locationScript = pkgs.writeShellScript "location" '' + lon="" + lat="" + + while IFS= read -r line; do + if [[ "$line" == *"Latitude"* ]]; then + lat=$(echo "$line" | awk '{ gsub(/[" ]/, "", $2); printf("%.2f", $2) }') + elif [[ "$line" == *"Longitude"* ]]; then + lon=$(echo "$line" | awk '{ gsub(/[" ]/, "", $2); printf("%.2f", $2) }') + fi + if [[ -n "$lat" && -n "$lon" ]]; then + break + fi + # -a 4 -- set accuracy to city + done < <(${pkgs.geoclue2}/libexec/geoclue-2.0/demos/where-am-i -a 4) + + # i've had issues including country *and* state here, so state has higher priority and falls back to country. works fine for my current place and home town, so good enough <3 + # zoom=10 -- set zoom to city + # addressdetails=1 -- get address details, includes neighborhood (if requested) to city + echo $(curl "https://nominatim.openstreetmap.org/reverse?lat=''${lat}&lon=''${lon}&addressdetails=1&zoom=10&format=json" | ${lib.getExe pkgs.jq} -r '.address | "\((to_entries[0].value)), \(.state // "\(.country)")"') + ''; + in { format = "{}°"; tooltip = true; + on-click = "${lib.getExe pkgs.gnome-weather}"; interval = 3600; # doxxing live stream - exec = "${lib.getExe pkgs.wttrbar} --location 'Corvallis, Oregon, United States' --hide-conditions --fahrenheit --mph"; + # edit: no longer doxxing, you will be remembered + exec = ''${lib.getExe pkgs.wttrbar} --location "$(${locationScript})" --hide-conditions --fahrenheit --mph''; return-type = "json"; }; };