Files
dotfiles/config/swiftbar/plugins/moon-phase.1h.sh
T
David F GliddenandClaude 389febb161 🚀 Complete machine migration setup with encrypted backups
- Added comprehensive configuration files for seamless migration
- SSH, GPG, Karabiner, iTerm2, Neofetch, SwiftBar configs
- Pass license management system with templates and documentation
- Enhanced shell functions with MAS updates and moon phase tracking
- Comprehensive encrypted backup system (GPG AES256)
- Included encrypted backups of all sensitive data
- BBEdit as default editor with proper configuration
- Fixed shell compatibility issues
- Merged existing .zsh configs with improvements

Security:
- All sensitive data is GPG encrypted (.gpg files)
- Private keys excluded from version control
- Only configs and encrypted backups are tracked

Following prime directive: durable, thoughtful solutions

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-28 23:10:36 +02:00

92 lines
2.5 KiB
Bash
Executable File

#!/bin/bash
# 🌙 SwiftBar Plugin: Symbolic Moon Phase Monitor
# Author: GPT + David
# Requires: curl, jq, awk
# Caches data for 6h to reduce API use
API_KEY="6ec71a8170214d828c08ba8bf2ca29e9"
CURL="/usr/bin/curl"
JQ="/usr/bin/jq"
AWK="/usr/bin/awk"
CACHE_FILE="$HOME/.cache/moonphase.json"
STATE_FILE="$HOME/.lunarstate"
MAX_AGE_HOURS=6
mkdir -p "$(dirname "$CACHE_FILE")"
# Check cache freshness
NEEDS_UPDATE=true
if [ -f "$CACHE_FILE" ]; then
MOD_UNIX=$(stat -f "%m" "$CACHE_FILE")
NOW_UNIX=$(date +%s)
AGE_HOURS=$(( (NOW_UNIX - MOD_UNIX) / 3600 ))
[ "$AGE_HOURS" -lt "$MAX_AGE_HOURS" ] && NEEDS_UPDATE=false
fi
# Fetch and cache
if [ "$NEEDS_UPDATE" = true ]; then
MOON_JSON=$($CURL -s "https://api.ipgeolocation.io/astronomy?apiKey=$API_KEY")
echo "$MOON_JSON" > "$CACHE_FILE"
else
MOON_JSON=$(cat "$CACHE_FILE")
fi
# Extract fields
PHASE=$(echo "$MOON_JSON" | $JQ -r '.moon_phase')
ILLUM=$(echo "$MOON_JSON" | $JQ -r '.moon_illumination_percentage' | $AWK '{printf "%.0f", $1}')
MOONRISE=$(echo "$MOON_JSON" | $JQ -r '.moonrise')
MOONSET=$(echo "$MOON_JSON" | $JQ -r '.moonset')
PHASE_LC=$(echo "$PHASE" | tr '[:upper:]' '[:lower:]')
# Ritual glyphs & poetic names
declare -A ICONS=(
["new_moon"]="🌑"
["waxing_crescent"]="🌒"
["first_quarter"]="🌓"
["waxing_gibbous"]="🌔"
["full_moon"]="🌕"
["waning_gibbous"]="🌖"
["last_quarter"]="🌗"
["waning_crescent"]="🌘"
)
declare -A POETIC=(
["new_moon"]="Veiled Mother"
["waxing_crescent"]="Hesitant Flame"
["first_quarter"]="Climbing Eye"
["waxing_gibbous"]="Gathering Tide"
["full_moon"]="Revealed Bride"
["waning_gibbous"]="Harvest Wane"
["last_quarter"]="Parting Mirror"
["waning_crescent"]="Waning Daughter"
)
ICON="${ICONS[$PHASE_LC]:-❓}"
POETIC_NAME="${POETIC[$PHASE_LC]:-Unknown Phase}"
# Direction
ARROW="⬆"
[[ "$PHASE_LC" =~ ^(full_moon|waning_gibbous|last_quarter|waning_crescent)$ ]] && ARROW="⬇"
# Ritual detection
NOTICE=""
if [[ "$PHASE_LC" == "full_moon" ]]; then
NOTICE="☽ FULL RITE ☾"
elif [[ "$PHASE_LC" == "new_moon" ]]; then
NOTICE="☉ NEW SILENCE ☉"
fi
# Output to menubar
echo "$ICON $ARROW ${ILLUM}%"
echo "---"
echo "Phase: $(echo "$PHASE" | tr '_' ' ' | awk '{for (i=1; i<=NF; i++) $i=toupper(substr($i,1,1)) substr($i,2)} 1')"
echo "Poetic: $POETIC_NAME"
echo "Illumination: ${ILLUM}%"
echo "Moonrise: $MOONRISE"
echo "Moonset: $MOONSET"
[ -n "$NOTICE" ] && echo "$NOTICE"
echo "Last updated: $(date -r "$CACHE_FILE" "+%H:%M %Z")"
# Optional: write state file for system rituals
echo "$PHASE_LC,$ILLUM,$POETIC_NAME,$NOTICE" > "$STATE_FILE"