From 3e4d5813f5e7122d400ec1afa154535ebc441fae Mon Sep 17 00:00:00 2001 From: steven-na Date: Fri, 1 May 2026 03:42:24 -0700 Subject: fix weather/nvim, copy script start --- arch/eww/.config/eww/scripts/day-with-suffix | 6 +++--- arch/eww/.config/eww/scripts/weather-fetch | 11 +++++++---- arch/eww/.config/eww/scripts/weather-notify | 11 ++++++++--- 3 files changed, 18 insertions(+), 10 deletions(-) (limited to 'arch/eww/.config') diff --git a/arch/eww/.config/eww/scripts/day-with-suffix b/arch/eww/.config/eww/scripts/day-with-suffix index f7c2243..111bd37 100755 --- a/arch/eww/.config/eww/scripts/day-with-suffix +++ b/arch/eww/.config/eww/scripts/day-with-suffix @@ -1,10 +1,10 @@ -#!/bin/sh +#!/usr/bin/env bash DaySuffix() { - case `date +%d` in + case `date +%-d` in 1|21|31) echo "st";; 2|22) echo "nd";; 3|23) echo "rd";; *) echo "th";; esac } -echo $(date +%d)`DaySuffix` +echo $(date +%-d)`DaySuffix` diff --git a/arch/eww/.config/eww/scripts/weather-fetch b/arch/eww/.config/eww/scripts/weather-fetch index 8fa53ac..9191edd 100755 --- a/arch/eww/.config/eww/scripts/weather-fetch +++ b/arch/eww/.config/eww/scripts/weather-fetch @@ -12,12 +12,15 @@ temp=$(echo "$data" | jq -r '.current_condition[0].temp_F') code=$(echo "$data" | jq -r '.current_condition[0].weatherCode') # ── Night check ──────────────────────────────────────────────────────────── -sunset_raw=$(echo "$data" | jq -r '.weather[0].astronomy[0].sunset') -sunset_epoch=$(date -d "today $sunset_raw" +%s 2>/dev/null) +sunrise_raw=$(echo "$data" | jq -r '.weather[0].astronomy[0].sunrise') +sunset_raw=$(echo "$data" | jq -r '.weather[0].astronomy[0].sunset') + +sunrise_epoch=$(date -d "today $sunrise_raw" +%s) +sunset_epoch=$(date -d "today $sunset_raw" +%s) now_epoch=$(date +%s) -is_night=false -[[ $now_epoch -ge $sunset_epoch ]] && is_night=true +is_night=false +[[ $now_epoch -ge $sunset_epoch || $now_epoch -lt $sunrise_epoch ]] && is_night=true # ── Moon phase ───────────────────────────────────────────────────────────── moon_icon() { local ref; ref=$(date -d "2000-01-06" +%s) # known new moon diff --git a/arch/eww/.config/eww/scripts/weather-notify b/arch/eww/.config/eww/scripts/weather-notify index fc95df0..9710ad4 100755 --- a/arch/eww/.config/eww/scripts/weather-notify +++ b/arch/eww/.config/eww/scripts/weather-notify @@ -15,10 +15,15 @@ high=$(echo "$data" | jq -r '.weather[0].maxtempF') low=$(echo "$data" | jq -r '.weather[0].mintempF') # ── Night / moon ─────────────────────────────────────────────────────────── -sunset_raw=$(echo "$data" | jq -r '.weather[0].astronomy[0].sunset') -sunset_epoch=$(date -d "today $sunset_raw" +%s 2>/dev/null) +sunrise_raw=$(echo "$data" | jq -r '.weather[0].astronomy[0].sunrise') +sunset_raw=$(echo "$data" | jq -r '.weather[0].astronomy[0].sunset') + +sunrise_epoch=$(date -d "today $sunrise_raw" +%s) +sunset_epoch=$(date -d "today $sunset_raw" +%s) +now_epoch=$(date +%s) + is_night=false -[[ $(date +%s) -ge $sunset_epoch ]] && is_night=true +[[ $now_epoch -ge $sunset_epoch || $now_epoch -lt $sunrise_epoch ]] && is_night=true moon_phase() { local ref; ref=$(date -d "2000-01-06" +%s) -- cgit v1.2.3