diff --git a/meta-opencentauri/recipes-apps/grumyscreen/files/grumpyscreen.cfg b/meta-opencentauri/recipes-apps/grumyscreen/files/grumpyscreen.cfg index c5940678..78cbb71b 100644 --- a/meta-opencentauri/recipes-apps/grumyscreen/files/grumpyscreen.cfg +++ b/meta-opencentauri/recipes-apps/grumyscreen/files/grumpyscreen.cfg @@ -1,3 +1,8 @@ +# ----- +# PLEASE DO NOT EDIT THIS FILE. EDIT grumpyscreen.cfg INSTEAD. +# UPDATES WILL RESET THIS FILE. YOUR EDITS WILL BE LOST WHEN UPDATING. +# ----- + [default_macros] cooldown: TURN_OFF_HEATERS extrude: _GUPPYSCREEN_EXTRUDE EXTRUDER_TEMP={} EXTRUDE_LEN={} SPEED={} diff --git a/meta-opencentauri/recipes-apps/grumyscreen/files/grumpyscreen.init b/meta-opencentauri/recipes-apps/grumyscreen/files/grumpyscreen.init index ea6c2228..2220d1ed 100644 --- a/meta-opencentauri/recipes-apps/grumyscreen/files/grumpyscreen.init +++ b/meta-opencentauri/recipes-apps/grumyscreen/files/grumpyscreen.init @@ -10,13 +10,48 @@ GRUMPYSCREEN_EXEC=/usr/bin/grumpyscreen PIDFILE=/var/run/gui.pid +CONFIG_FILE="/etc/klipper/config/grumpyscreen-readonly/grumpyscreen.cfg" +CONFIG_OVERRIDE_FILE="/etc/klipper/config/grumpyscreen.cfg" +CONFIG_VERSION="20260518" +CONFIG_VERSION_FILE="/etc/grumpyscreen-config.ver" +CONFIG_BACKUP_DIR="/etc/klipper/config/config-backups" -export CONFIG_FILE=/etc/klipper/config/grumpyscreen.cfg +export CONFIG_FILE +export CONFIG_OVERRIDE_FILE + +ensure_grumpyscreen_config_version() { + current_version="" + + if [ -f "$CONFIG_VERSION_FILE" ]; then + current_version="$(tr -d '[:space:]' < "$CONFIG_VERSION_FILE" 2>/dev/null)" + else + current_version="" #reset configs + echo "$current_version" > "$CONFIG_VERSION_FILE" || return 1 + fi + + if [ "$current_version" = "$CONFIG_VERSION" ]; then + return 0 + fi + + if [ -f "$CONFIG_OVERRIDE_FILE" ]; then + backup_timestamp="$(date +%Y%m%d_%H%M%S)" || return 1 + backup_file="$CONFIG_BACKUP_DIR/grumpyscreen-$backup_timestamp.cfg" + + mkdir -p "$CONFIG_BACKUP_DIR" || return 1 + cp "$CONFIG_OVERRIDE_FILE" "$backup_file" || return 1 + echo "# Add other extra configuration here.\n" > "$CONFIG_OVERRIDE_FILE" + fi + + printf '%s\n' "$CONFIG_VERSION" > "$CONFIG_VERSION_FILE" || return 1 +} case "$1" in start) echo "Starting grumpyscreen..." - # Start grumpyscreen in the background + if ! ensure_grumpyscreen_config_version; then + echo "Failed to update Grumpyscreen config version state" + exit 1 + fi start-stop-daemon -S -b -m -p "$PIDFILE" -x "$GRUMPYSCREEN_EXEC" ;; stop) diff --git a/meta-opencentauri/recipes-apps/grumyscreen/grumpyscreen_20260518.bb b/meta-opencentauri/recipes-apps/grumyscreen/grumpyscreen_20260518.bb index 11774c03..670636dd 100644 --- a/meta-opencentauri/recipes-apps/grumyscreen/grumpyscreen_20260518.bb +++ b/meta-opencentauri/recipes-apps/grumyscreen/grumpyscreen_20260518.bb @@ -87,7 +87,10 @@ do_install() { install -d ${D}${sysconfdir}/klipper install -d ${D}${sysconfdir}/klipper/config - install -m 0644 ${WORKDIR}/grumpyscreen.cfg ${D}${sysconfdir}/klipper/config/ + echo "# Add other extra configuration here.\n" > ${D}${sysconfdir}/klipper/config/grumpyscreen.cfg + + install -d ${D}${sysconfdir}/klipper/config/grumpyscreen-readonly + install -m 0644 ${WORKDIR}/grumpyscreen.cfg ${D}${sysconfdir}/klipper/config/grumpyscreen-readonly/ install -d ${D}${sysconfdir}/init.d install -m 0755 ${WORKDIR}/grumpyscreen.init ${D}${sysconfdir}/init.d/grumpyscreen @@ -97,7 +100,11 @@ FILES:${PN} = " \ ${bindir}/grumpyscreen \ ${datadir}/grumpyscreen \ ${sysconfdir}/klipper/config/grumpyscreen.cfg \ + ${sysconfdir}/klipper/config/grumpyscreen-readonly/grumpyscreen.cfg \ ${sysconfdir}/init.d/grumpyscreen \ " -CONFFILES:${PN} = "${sysconfdir}/klipper/config/grumpyscreen.cfg" +CONFFILES:${PN} = " \ + ${sysconfdir}/klipper/config/grumpyscreen.cfg \ + ${sysconfdir}/klipper/config/grumpyscreen-readonly/grumpyscreen.cfg \ +"