From 2fc3e6773e10b1016168ff74eeacfd8a42815121 Mon Sep 17 00:00:00 2001 From: Ewan Croft Date: Fri, 3 Jul 2026 19:55:31 +0100 Subject: [PATCH] Bundle sysinfo watcher in minefetch repo; use Minefetch-specific fastfetch config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Move scripts/sysinfo-watcher.sh to minefetch repo (single source of truth) - mc-server lib/fastfetch.sh and setup_minefetch.sh now reference minefetch repo paths - Remove mc-server/scripts/sysinfo-watcher.sh - Add scripts/fastfetch-config.jsonc — only includes the 7 modules the plugin parses - All fastfetch calls use --config pointing to this config --- lib/fastfetch.sh | 5 +++-- scripts/setup_minefetch.sh | 5 +++-- scripts/sysinfo-watcher.sh | 33 --------------------------------- 3 files changed, 6 insertions(+), 37 deletions(-) delete mode 100644 scripts/sysinfo-watcher.sh diff --git a/lib/fastfetch.sh b/lib/fastfetch.sh index 6fac0dc..fc8de56 100644 --- a/lib/fastfetch.sh +++ b/lib/fastfetch.sh @@ -3,8 +3,9 @@ # sysinfo watcher so the /minefetch in-game command shows fresh host data. # Requires: shared.sh -SYSINFO_WATCHER="$(dirname "$(dirname "${BASH_SOURCE[0]}")")/scripts/sysinfo-watcher.sh" +SYSINFO_WATCHER="/Volumes/Storage/Developer/Git/minefetch/scripts/sysinfo-watcher.sh" SYSINFO_DIR="${MC_SYSINFO_DIR:-/Volumes/Storage/Server/MC/sysinfo}" +SYSINFO_CONFIG="${MC_SYSINFO_CONFIG:-/Volumes/Storage/Developer/Git/minefetch/scripts/fastfetch-config.jsonc}" setup_fastfetch() { print_header "Setting up fastfetch + sysinfo watcher for Minefetch" @@ -62,7 +63,7 @@ setup_fastfetch() { print_success "Sysinfo watcher started (PID $pid)" # Generate initial host.json - fastfetch --format json > "$SYSINFO_DIR/host.json.tmp" + fastfetch --config "$SYSINFO_CONFIG" --format json > "$SYSINFO_DIR/host.json.tmp" mv "$SYSINFO_DIR/host.json.tmp" "$SYSINFO_DIR/host.json" print_success "Initial host.json written to $SYSINFO_DIR/host.json" fi diff --git a/scripts/setup_minefetch.sh b/scripts/setup_minefetch.sh index 9d5d7e7..8370387 100644 --- a/scripts/setup_minefetch.sh +++ b/scripts/setup_minefetch.sh @@ -11,6 +11,7 @@ echo "=========================================" echo "" SYSINFO_DIR="${MC_SYSINFO_DIR:-/Volumes/Storage/Server/MC/sysinfo}" +SYSINFO_CONFIG="${MC_SYSINFO_CONFIG:-/Volumes/Storage/Developer/Git/minefetch/scripts/fastfetch-config.jsonc}" # Detect operating system detect_os() { @@ -74,7 +75,7 @@ install_fastfetch_yum() { start_watcher() { local script_dir script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - local watcher="$script_dir/sysinfo-watcher.sh" + local watcher="/Volumes/Storage/Developer/Git/minefetch/scripts/sysinfo-watcher.sh" local pid mkdir -p "$SYSINFO_DIR" @@ -144,7 +145,7 @@ fi echo "" echo "Generating initial host.json..." mkdir -p "$SYSINFO_DIR" -fastfetch --format json > "$SYSINFO_DIR/host.json.tmp" +fastfetch --config "$SYSINFO_CONFIG" --format json > "$SYSINFO_DIR/host.json.tmp" mv "$SYSINFO_DIR/host.json.tmp" "$SYSINFO_DIR/host.json" echo "Written to $SYSINFO_DIR/host.json" diff --git a/scripts/sysinfo-watcher.sh b/scripts/sysinfo-watcher.sh deleted file mode 100644 index ebe157e..0000000 --- a/scripts/sysinfo-watcher.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -# sysinfo-watcher.sh — Host-side file watcher for on-demand sysinfo refresh. -# -# Polls the sysinfo directory for a .refresh trigger file. When the Minefetch -# plugin creates one (triggered by a player's /minefetch command), this watcher -# deletes the trigger and regenerates host.json with fresh fastfetch output. -# -# Usage: -# ./scripts/sysinfo-watcher.sh [sysinfo-dir] -# -# The default sysinfo dir matches the MC_SYSINFO_DIR default in compose.yml. - -set -euo pipefail - -SYSINFO_DIR="${1:-/Volumes/Storage/Server/MC/sysinfo}" -SYSINFO_FILE="$SYSINFO_DIR/host.json" -TRIGGER_FILE="$SYSINFO_DIR/.refresh" - -if ! command -v fastfetch &> /dev/null; then - echo "Error: fastfetch not found. Install it with: brew install fastfetch" - exit 1 -fi - -echo "Watching $SYSINFO_DIR for .refresh triggers..." - -while true; do - if [ -f "$TRIGGER_FILE" ]; then - rm -f "$TRIGGER_FILE" - fastfetch --format json > "$SYSINFO_FILE.tmp" - mv "$SYSINFO_FILE.tmp" "$SYSINFO_FILE" - fi - sleep 0.5 -done -- 2.51.2