macbook-setup/temp-watch.sh
rene 722bd849f9 Initial commit: Linux-Setup für MacBook Pro 13" und 16"
Vollautomatisches Post-Install-Setup für Ubuntu 24.04 auf MacBook Pro
Late 2013 (13") und Mid 2014 (16" mit Nvidia Optimus). Enthält:

- setup.sh: Komplettes Post-Install-Skript (Pakete, Xubuntu, Brave,
  PrusaSlicer, oh-my-zsh, Claude Code, Dotfiles via Forgejo/Stow,
  mbpfan, thermald, TLP, WireGuard, Lokalisierung DE)
- build-iso.sh: Ubuntu Autoinstall ISO für Ventoy erstellen
- user-data/meta-data: cloud-init Autoinstall-Konfiguration
- mbpfan-13.conf / mbpfan-16.conf: Modellspezifische Lüftersteuerung
- hid_apple.conf / keyboard: Deutsche Mac-Tastaturbelegung + Fn-Tasten
- blacklist-nvidia.conf: Optionaler Nvidia/nouveau-Blacklist
- temp-watch.sh: CPU-Temperaturüberwachung mit Desktop-Notification

Infrastruktur-Abhängigkeiten:
- Dotfiles: git.motocamp.de/rene/dotfiles.git (via GNU Stow)
- DiskStation 10.47.11.10 (SMTP, IMAP, Synology Drive)
- WireGuard-VPN 10.13.13.x ins Heimnetz 10.47.11.0/24
2026-03-07 15:27:48 +01:00

27 lines
966 B
Bash

#!/bin/bash
# temp-watch.sh — Temperaturüberwachung mit Desktop-Notification
# Systemd-Service oder XFCE Autostart
# Warnt bei CPU-Temperatur > THRESHOLD Grad Celsius
THRESHOLD=85
INTERVAL=30
while true; do
TEMP=$(sensors 2>/dev/null | grep -E "Core 0|Package id" | grep -oP '\+\K[0-9.]+' | sort -n | tail -1)
if [[ -n "$TEMP" ]] && (( $(echo "$TEMP > $THRESHOLD" | bc -l) )); then
# Aktuellen Desktop-User ermitteln
DESK_USER=$(who | grep -m1 '(:0)' | awk '{print $1}')
if [[ -n "$DESK_USER" ]]; then
USER_ID=$(id -u "$DESK_USER")
DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/${USER_ID}/bus" \
sudo -u "$DESK_USER" notify-send \
-u critical \
-i dialog-warning \
"🌡 CPU-Temperatur kritisch" \
"${TEMP}°C — Lüfter prüfen!\nmbpfan: $(systemctl is-active mbpfan)"
fi
fi
sleep "$INTERVAL"
done