Move location/music/ntfy config to .env; add paths to notifications
sky-cam.conf:
- MUSIC_DIR now uses override pattern (MUSIC_DIR="${MUSIC_DIR:-$SCRIPT_DIR/music}")
so the real path can be set in .env without hardcoding it
- LATITUDE/LONGITUDE use override pattern; set real coords in .env to keep
location private and out of git
- NTFY_URL now uses override pattern with empty default; set in .env
- NTFY_ENABLED moved out of comments into active config with false default
sunrise.py:
- Reads .env after sky-cam.conf so .env values override (same source order
as sky-cam.conf itself)
- Handles ${VAR:-default} bash syntax when parsing sky-cam.conf values
All completion notifications now include the full output file path so you
can tell at a glance where the file landed:
- daily_sunrise_video.sh: "filename — Xs, sunrise at HH:MM | /full/path"
- 4-seasons.sh: "filename — Xs | /full/path"
- montage-mvt.sh: "filename | checks | /full/path | verify: ..."
- year-end-join.sh: "filename — Xmin | /full/path" (also adds [cam] to title)
install.sh .env.example now includes LATITUDE, LONGITUDE, MUSIC_DIR, NTFY_URL
https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
This commit is contained in:
+22
-8
@@ -1,26 +1,40 @@
|
||||
#!/usr/bin/env python3
|
||||
from datetime import datetime
|
||||
import pathlib
|
||||
import re
|
||||
|
||||
import pytz
|
||||
from suntime import Sun
|
||||
|
||||
# Locate sky-cam.conf next to this script (works regardless of cwd).
|
||||
_here = pathlib.Path(__file__).resolve().parent
|
||||
|
||||
def _read_conf(path):
|
||||
conf = {}
|
||||
with open(path) as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if line and not line.startswith('#') and '=' in line:
|
||||
try:
|
||||
with open(path) as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if not line or line.startswith('#') or '=' not in line:
|
||||
continue
|
||||
k, v = line.split('=', 1)
|
||||
conf[k.strip()] = v.strip()
|
||||
k = k.strip()
|
||||
v = v.strip().strip('"').strip("'")
|
||||
# Extract default from bash ${VAR:-default} pattern
|
||||
m = re.match(r'^\$\{[^}]+:-([^}]*)\}$', v)
|
||||
if m:
|
||||
v = m.group(1).strip('"').strip("'")
|
||||
conf[k] = v
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
return conf
|
||||
|
||||
conf = _read_conf(_here / 'sky-cam.conf')
|
||||
# .env overrides sky-cam.conf — mirrors the sourcing order at the bottom of sky-cam.conf
|
||||
conf.update(_read_conf(_here / '.env'))
|
||||
|
||||
for _key in ('LATITUDE', 'LONGITUDE', 'TIMEZONE'):
|
||||
if _key not in conf:
|
||||
raise SystemExit(f"sunrise.py: {_key} not set in sky-cam.conf")
|
||||
if not conf.get(_key):
|
||||
raise SystemExit(f"sunrise.py: {_key} not set in sky-cam.conf or .env")
|
||||
|
||||
latitude = float(conf['LATITUDE'])
|
||||
longitude = float(conf['LONGITUDE'])
|
||||
|
||||
Reference in New Issue
Block a user