Files
mev-beta/orig/scripts/battery-calibrate.sh
Administrator c54c569f30 refactor: move all remaining files to orig/ directory
Completed clean root directory structure:
- Root now contains only: .git, .env, docs/, orig/
- Moved all remaining files and directories to orig/:
  - Config files (.claude, .dockerignore, .drone.yml, etc.)
  - All .env variants (except active .env)
  - Git config (.gitconfig, .github, .gitignore, etc.)
  - Tool configs (.golangci.yml, .revive.toml, etc.)
  - Documentation (*.md files, @prompts)
  - Build files (Dockerfiles, Makefile, go.mod, go.sum)
  - Docker compose files
  - All source directories (scripts, tests, tools, etc.)
  - Runtime directories (logs, monitoring, reports)
  - Dependency files (node_modules, lib, cache)
  - Special files (--delete)

- Removed empty runtime directories (bin/, data/)

V2 structure is now clean:
- docs/planning/ - V2 planning documents
- orig/ - Complete V1 codebase preserved
- .env - Active environment config (not in git)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-10 10:53:05 +01:00

44 lines
1.2 KiB
Bash

#!/usr/bin/env bash
# Battery Calibration Script for Arch Linux on MacBook Air
# Helps safely discharge/charge battery to recalibrate SMC.
LOGFILE="$HOME/battery_calibration.log"
THRESHOLD_SHUTDOWN=2 # % at which system will auto-shutdown
THRESHOLD_WARN1=10
THRESHOLD_WARN2=5
get_capacity() {
cat /sys/class/power_supply/BAT0/capacity
}
get_status() {
cat /sys/class/power_supply/BAT0/status
}
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" | tee -a "$LOGFILE"
}
log "=== Starting battery calibration session ==="
while true; do
CAPACITY=$(get_capacity)
STATUS=$(get_status)
log "Battery: $CAPACITY% | Status: $STATUS"
if [[ "$STATUS" == "Discharging" ]]; then
if (( CAPACITY <= THRESHOLD_WARN1 && CAPACITY > THRESHOLD_WARN2 )); then
notify-send "Battery Calibration" "Battery low: $CAPACITY%. Save work."
elif (( CAPACITY <= THRESHOLD_WARN2 && CAPACITY > THRESHOLD_SHUTDOWN )); then
notify-send "Battery Calibration" "Battery critical: $CAPACITY%. Shutdown soon."
elif (( CAPACITY <= THRESHOLD_SHUTDOWN )); then
log "Battery reached $CAPACITY%. Shutting down for full discharge..."
systemctl poweroff
fi
fi
sleep 60 # check every minute
done