Files
ai-for-dummies/submitted-skills/Vinicius Nascimento/skills/lunch-time/lunch.sh
T
2026-09-04 00:36:01 -03:00

20 lines
600 B
Bash

#!/bin/bash
# Log start of lunch break.
set -euo pipefail
F="$HOME/long-day-factory.json"
TS="$(python3 -c 'import datetime;print(datetime.datetime.now().astimezone().isoformat(timespec="seconds"))')"
if [ ! -f "$F" ]; then
printf '{\n "startTime": null,\n "lunchTime": null,\n "backToWork": null\n}\n' > "$F"
fi
tmp="$(mktemp)"
jq --arg ts "$TS" '.lunchTime = $ts' "$F" > "$tmp" && mv "$tmp" "$F"
echo "Lunch break started at $TS"
if [ "$(jq -r '.startTime' "$F")" = "null" ]; then
echo "WARNING: startTime is not set — did you skip long-day-start this morning?"
fi