time zone and weather is now location based!!
This commit is contained in:
parent
696e37e35c
commit
72f438bdae
4 changed files with 55 additions and 16 deletions
|
@ -13,10 +13,7 @@ in {
|
|||
enable = true;
|
||||
tray = true;
|
||||
|
||||
# portland, oregon
|
||||
latitude = 45.3112;
|
||||
longitude = -122.4055;
|
||||
provider = "manual";
|
||||
provider = "geoclue2";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue