L'ancien triple-tap via finger_trace dessinait des points noirs (outil de demo FBInk), ne respawnait pas (mort definitif si le process tombait) et le tactile ne reveille pas l'appareil. Le power, lui, n'emet que des scancodes MSC_SCAN parasites (etat de charge USB). Les boutons de page emettent des EV_KEY propres (codes 193/194). reboot_watcher.sh: lit l'evdev (FD persistant, pas de perte d'evenements), declenche sur 3 press EV_KEY < 3 s, boucle de respawn. Plus de finger_trace. Refresh: full force au (re)demarrage (reset=1 cote client -> oubli de prev_image cote serveur) pour eviter un refresh partiel pose sur un ecran efface par le reboot.
66 lines
3.0 KiB
Bash
Executable File
66 lines
3.0 KiB
Bash
Executable File
#!/bin/sh
|
|
# Monitorink — point d'entrée lancé par NickelMenu.
|
|
#
|
|
# Prend le contrôle complet de l'appareil en TUANT Nickel (sinon Nickel auto-suspend
|
|
# l'appareil et coupe le WiFi, en conflit avec notre boucle). On siphonne d'abord les
|
|
# variables d'environnement WiFi de Nickel (WIFI_MODULE/PLATFORM/INTERFACE) pour pouvoir
|
|
# gérer le WiFi nous-mêmes. À l'arrêt (entrée « Monitorink STOP »), on REBOOT pour
|
|
# restaurer Nickel et l'usage normal de la liseuse.
|
|
export LC_ALL="en_US.UTF-8"
|
|
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
|
|
|
|
BASE="/mnt/onboard/.adds/Monitorink"
|
|
LOG="$BASE/monitorink.log"
|
|
cd "$BASE" || exit 1
|
|
|
|
# --- Configuration ---
|
|
export MONITORINK_URL="http://192.168.0.43:8899/image.png"
|
|
export MONITORINK_REFRESH=300 # PROD: refresh partiel 5 min
|
|
# Cadence du full refresh : côté SERVEUR via MONITORINK_FULL_EVERY (PROD=12 ~1 h à 5 min/cycle).
|
|
|
|
echo "===== monitorink start $(date) =====" >> "$LOG"; sync
|
|
|
|
# --- Gouverneur CPU économe ---
|
|
CPUFREQ="/sys/devices/system/cpu/cpufreq/policy0"
|
|
[ -d "$CPUFREQ" ] || CPUFREQ="/sys/devices/system/cpu/cpu0/cpufreq"
|
|
if grep -q ondemand "$CPUFREQ/scaling_available_governors" 2>/dev/null; then
|
|
echo ondemand > "$CPUFREQ/scaling_governor" 2>/dev/null
|
|
fi
|
|
|
|
# --- Prendre le contrôle : siphonner l'env Nickel (WiFi) puis tuer Nickel ---
|
|
if pkill -0 nickel 2>/dev/null; then
|
|
NICKEL_PID="$(pidof -s nickel)"
|
|
if [ -n "$NICKEL_PID" ]; then
|
|
NENV=$(tr '\0' '\n' < "/proc/$NICKEL_PID/environ" 2>/dev/null \
|
|
| grep -E '^(WIFI_MODULE|INTERFACE|NICKEL_HOME|DBUS_SESSION_BUS_ADDRESS|LANG|PLATFORM|PRODUCT)=')
|
|
[ -n "$NENV" ] && export $NENV
|
|
fi
|
|
UDEV_PID="$(pidof -s udevd)"
|
|
if [ -n "$UDEV_PID" ]; then
|
|
[ -z "$PRODUCT" ] && { V=$(tr '\0' '\n' < "/proc/$UDEV_PID/environ" 2>/dev/null | grep -E '^PRODUCT='); [ -n "$V" ] && export $V; }
|
|
[ -z "$PLATFORM" ] && { V=$(tr '\0' '\n' < "/proc/$UDEV_PID/environ" 2>/dev/null | grep -E '^PLATFORM='); [ -n "$V" ] && export $V; }
|
|
fi
|
|
[ -z "$INTERFACE" ] && export INTERFACE="eth0"
|
|
echo "[monitorink] WIFI_MODULE=$WIFI_MODULE PLATFORM=$PLATFORM INTERFACE=$INTERFACE PRODUCT=$PRODUCT" >> "$LOG"; sync
|
|
|
|
sync
|
|
killall -q -TERM nickel hindenburg sickel fickel fontickel adobehost foxitpdf iink dhcpcd-dbus dhcpcd 2>/dev/null
|
|
t=0; while pkill -0 nickel 2>/dev/null; do [ "$t" -ge 16 ] && break; usleep 250000; t=$((t + 1)); done
|
|
rm -f /tmp/nickel-hardware-status
|
|
fi
|
|
[ -z "$INTERFACE" ] && export INTERFACE="eth0"
|
|
|
|
# Synchronise l'horloge RTC (sinon rtcwake calcule mal le réveil).
|
|
hwclock -w -u 2>/dev/null
|
|
|
|
# Watcher bouton power -> reboot logiciel (en arrière-plan, Nickel mort).
|
|
# Premier calage : préfixer par MONITORINK_PWR_DEBUG=1 pour logger device/format dans le log.
|
|
sh "$BASE/reboot_watcher.sh" &
|
|
|
|
# Boucle bloquante. À la sortie (STOP tue monitorinkloop.sh), on reboot pour restaurer Nickel.
|
|
sh "$BASE/monitorinkloop.sh" >> "$LOG" 2>&1
|
|
|
|
echo "===== monitorink stop $(date) — reboot =====" >> "$LOG"; sync
|
|
sleep 1
|
|
reboot
|