From 2d8b772d7275b4650b30729d54ba9e8447f44a62 Mon Sep 17 00:00:00 2001 From: Debian Date: Wed, 30 Sep 2026 08:02:04 +0000 Subject: [PATCH 1/3] check disk space --- meta-opencentauri/images/cosmos-image-base.bb | 1 + .../recipes-apps/klipper/files/macros.cfg | 18 ++++++++++++++++ .../recipes-apps/klipper/files/shell.cfg | 14 ++++++++++++- .../recipes-data/check-disk/check-disk_0.1.bb | 21 +++++++++++++++++++ .../check-disk/files/check-disk.sh | 21 +++++++++++++++++++ 5 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 meta-opencentauri/recipes-data/check-disk/check-disk_0.1.bb create mode 100644 meta-opencentauri/recipes-data/check-disk/files/check-disk.sh diff --git a/meta-opencentauri/images/cosmos-image-base.bb b/meta-opencentauri/images/cosmos-image-base.bb index 478349a5..e69774c1 100644 --- a/meta-opencentauri/images/cosmos-image-base.bb +++ b/meta-opencentauri/images/cosmos-image-base.bb @@ -47,6 +47,7 @@ CORE_IMAGE_EXTRA_INSTALL += "\ afc \ tmc-autotune \ dragonbreath \ + check-disk \ " INITRAMFS_IMAGE = "core-image-tiny-initramfs" diff --git a/meta-opencentauri/recipes-apps/klipper/files/macros.cfg b/meta-opencentauri/recipes-apps/klipper/files/macros.cfg index 906cbd96..6eb82a37 100644 --- a/meta-opencentauri/recipes-apps/klipper/files/macros.cfg +++ b/meta-opencentauri/recipes-apps/klipper/files/macros.cfg @@ -982,3 +982,21 @@ gcode: M300 S2000 P50 TARGET={T} M300 S2500 P50 TARGET={T} M300 S4000 P50 TARGET={T} + +[gcode_macro _DISK_WARN_DIALOG] +description: display popup on low disk +gcode: + RESPOND TYPE=command MSG="action:prompt_end" + RESPOND TYPE=command MSG="action:prompt_begin Low Storage Warning" + {% set msg = params.MSG|default("A filesystem is running low on space.") %} + RESPOND TYPE=command MSG="action:prompt_text {msg}" + RESPOND TYPE=command MSG="action:prompt_button Dismiss|CLOSE_DISK_WARN_DIALOG|info" + RESPOND TYPE=command MSG="action:prompt_show" + +[gcode_macro CLOSE_DISK_WARN_DIALOG] +description: Safely terminates the UI alert state from the backend side +gcode: + RESPOND TYPE=command MSG="action:prompt_end" + + + diff --git a/meta-opencentauri/recipes-apps/klipper/files/shell.cfg b/meta-opencentauri/recipes-apps/klipper/files/shell.cfg index 9aa5cefc..957140e3 100644 --- a/meta-opencentauri/recipes-apps/klipper/files/shell.cfg +++ b/meta-opencentauri/recipes-apps/klipper/files/shell.cfg @@ -107,4 +107,16 @@ initial_duration: 60 gcode: {% if printer.idle_timeout.state in ["Idle", "Ready"] and printer.print_stats.state == "standby" %} RUN_SHELL_COMMAND CMD=CHECK_FOR_UPDATES - {% endif %} \ No newline at end of file + {% endif %} + +[gcode_shell_command CHECK_DISK] +command: sh /user-resource/check-disk4 +timeout: 5 +verbose: True + +[delayed_gcode check_disk_startup] +initial_duration: 60 +gcode: + RUN_SHELL_COMMAND CMD=CHECK_DISK + + diff --git a/meta-opencentauri/recipes-data/check-disk/check-disk_0.1.bb b/meta-opencentauri/recipes-data/check-disk/check-disk_0.1.bb new file mode 100644 index 00000000..0d42ca31 --- /dev/null +++ b/meta-opencentauri/recipes-data/check-disk/check-disk_0.1.bb @@ -0,0 +1,21 @@ +DESCRIPTION = "COSMOS Disk Space Checker" +LICENSE = "GPL-3.0-only" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-3.0-only;md5=c79ff39f19dfec6d293b95dea7b07891" + +SRC_URI = "file://check-disk.sh" + +inherit allarch + +RDEPENDS:${PN} = " \ + curl \ + screen-actions \ +" + +do_install[vardeps] += "DISTRO_VERSION" + +do_install() { + install -d ${D}${bindir} + install -m 0755 ${UNPACKDIR}/check-disk.sh ${D}${bindir}/check-disk +} + +FILES:${PN} = "${bindir}/check-disk" diff --git a/meta-opencentauri/recipes-data/check-disk/files/check-disk.sh b/meta-opencentauri/recipes-data/check-disk/files/check-disk.sh new file mode 100644 index 00000000..2c00ae1d --- /dev/null +++ b/meta-opencentauri/recipes-data/check-disk/files/check-disk.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +MOONRAKER_URL="http://localhost/printer/gcode/script" + +ALERTS="" +while read -r line; do + if [ -n "$line" ]; then + ALERTS="${ALERTS}${line}. " + fi +done < <(df -P /user-resource /board-resource | awk 'NR>1 {sub(/%/, "", $5); if ($5 > 90) print $6 " is at " $5 "%"}') + +if [ -n "$ALERTS" ]; then + MACRO_CALL="_DISK_WARN_DIALOG MSG=\"ALERT: ${ALERTS}\"" + + ENCODED_CALL=$(echo "$MACRO_CALL" | sed 's/ /%20/g') + + curl -s -X POST "${MOONRAKER_URL}?script=${ENCODED_CALL}" > /dev/null +fi + + + From de2dca776ce29b23f8ed67abdcaf6fc95f3a135e Mon Sep 17 00:00:00 2001 From: "K. Brant Niggemyer" Date: Wed, 30 Sep 2026 04:26:35 -0400 Subject: [PATCH 2/3] Update shell command for disk check script update from test path to deployed path --- meta-opencentauri/recipes-apps/klipper/files/shell.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta-opencentauri/recipes-apps/klipper/files/shell.cfg b/meta-opencentauri/recipes-apps/klipper/files/shell.cfg index 957140e3..872e0912 100644 --- a/meta-opencentauri/recipes-apps/klipper/files/shell.cfg +++ b/meta-opencentauri/recipes-apps/klipper/files/shell.cfg @@ -110,7 +110,7 @@ gcode: {% endif %} [gcode_shell_command CHECK_DISK] -command: sh /user-resource/check-disk4 +command: sh check-disk timeout: 5 verbose: True From 7e14bc85fef969c429e4deb1f1e46dd35dfc2948 Mon Sep 17 00:00:00 2001 From: Debian Date: Thu, 1 Oct 2026 00:12:57 +0000 Subject: [PATCH 3/3] updates based on PR review --- .../recipes-apps/klipper/files/macros.cfg | 18 ------------------ .../recipes-apps/klipper/files/shell.cfg | 2 +- .../check-disk/files/check-disk.sh | 8 +------- 3 files changed, 2 insertions(+), 26 deletions(-) diff --git a/meta-opencentauri/recipes-apps/klipper/files/macros.cfg b/meta-opencentauri/recipes-apps/klipper/files/macros.cfg index 6eb82a37..906cbd96 100644 --- a/meta-opencentauri/recipes-apps/klipper/files/macros.cfg +++ b/meta-opencentauri/recipes-apps/klipper/files/macros.cfg @@ -982,21 +982,3 @@ gcode: M300 S2000 P50 TARGET={T} M300 S2500 P50 TARGET={T} M300 S4000 P50 TARGET={T} - -[gcode_macro _DISK_WARN_DIALOG] -description: display popup on low disk -gcode: - RESPOND TYPE=command MSG="action:prompt_end" - RESPOND TYPE=command MSG="action:prompt_begin Low Storage Warning" - {% set msg = params.MSG|default("A filesystem is running low on space.") %} - RESPOND TYPE=command MSG="action:prompt_text {msg}" - RESPOND TYPE=command MSG="action:prompt_button Dismiss|CLOSE_DISK_WARN_DIALOG|info" - RESPOND TYPE=command MSG="action:prompt_show" - -[gcode_macro CLOSE_DISK_WARN_DIALOG] -description: Safely terminates the UI alert state from the backend side -gcode: - RESPOND TYPE=command MSG="action:prompt_end" - - - diff --git a/meta-opencentauri/recipes-apps/klipper/files/shell.cfg b/meta-opencentauri/recipes-apps/klipper/files/shell.cfg index 872e0912..0ac777e0 100644 --- a/meta-opencentauri/recipes-apps/klipper/files/shell.cfg +++ b/meta-opencentauri/recipes-apps/klipper/files/shell.cfg @@ -110,7 +110,7 @@ gcode: {% endif %} [gcode_shell_command CHECK_DISK] -command: sh check-disk +command: check-disk timeout: 5 verbose: True diff --git a/meta-opencentauri/recipes-data/check-disk/files/check-disk.sh b/meta-opencentauri/recipes-data/check-disk/files/check-disk.sh index 2c00ae1d..831d21e6 100644 --- a/meta-opencentauri/recipes-data/check-disk/files/check-disk.sh +++ b/meta-opencentauri/recipes-data/check-disk/files/check-disk.sh @@ -1,7 +1,5 @@ #!/bin/sh -MOONRAKER_URL="http://localhost/printer/gcode/script" - ALERTS="" while read -r line; do if [ -n "$line" ]; then @@ -10,11 +8,7 @@ while read -r line; do done < <(df -P /user-resource /board-resource | awk 'NR>1 {sub(/%/, "", $5); if ($5 > 90) print $6 " is at " $5 "%"}') if [ -n "$ALERTS" ]; then - MACRO_CALL="_DISK_WARN_DIALOG MSG=\"ALERT: ${ALERTS}\"" - - ENCODED_CALL=$(echo "$MACRO_CALL" | sed 's/ /%20/g') - - curl -s -X POST "${MOONRAKER_URL}?script=${ENCODED_CALL}" > /dev/null + uiprompt "Disk Space Warning" "ALERT: ${ALERTS}" fi