diff --git a/build.gradle b/build.gradle index f03f187..0993f07 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { id 'com.gradleup.shadow' version '9.4.3' } -version = '1.2.0' +version = '1.2.1' repositories { mavenCentral() diff --git a/scripts/fastfetch-config.jsonc b/scripts/fastfetch-config.jsonc new file mode 100644 index 0000000..fafc515 --- /dev/null +++ b/scripts/fastfetch-config.jsonc @@ -0,0 +1,14 @@ +{ + // Fastfetch config for Minefetch — only modules parsed by the plugin. + // Used via: fastfetch --config scripts/fastfetch-config.jsonc --format json + "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/master/doc/json_schema.json", + "modules": [ + "os", + "kernel", + "uptime", + "packages", + "cpu", + "memory", + "disk" + ] +} diff --git a/scripts/sysinfo-watcher.sh b/scripts/sysinfo-watcher.sh new file mode 100644 index 0000000..5bf99a6 --- /dev/null +++ b/scripts/sysinfo-watcher.sh @@ -0,0 +1,35 @@ +#!/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 + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +SYSINFO_DIR="${1:-/Volumes/Storage/Server/MC/sysinfo}" +SYSINFO_FILE="$SYSINFO_DIR/host.json" +TRIGGER_FILE="$SYSINFO_DIR/.refresh" +FASTFETCH_CONFIG="${MC_SYSINFO_CONFIG:-$SCRIPT_DIR/fastfetch-config.jsonc}" + +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 --config "$FASTFETCH_CONFIG" --format json > "$SYSINFO_FILE.tmp" + mv "$SYSINFO_FILE.tmp" "$SYSINFO_FILE" + fi + sleep 0.5 +done diff --git a/scripts/update-sysinfo.sh b/scripts/update-sysinfo.sh index cb1d310..e3f2caf 100644 --- a/scripts/update-sysinfo.sh +++ b/scripts/update-sysinfo.sh @@ -11,8 +11,10 @@ set -euo pipefail +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SYSINFO_DIR="${1:-/Volumes/Storage/Server/MC/sysinfo}" SYSINFO_FILE="$SYSINFO_DIR/host.json" +FASTFETCH_CONFIG="${2:-$SCRIPT_DIR/fastfetch-config.jsonc}" mkdir -p "$SYSINFO_DIR" @@ -21,7 +23,7 @@ if ! command -v fastfetch &> /dev/null; then exit 1 fi -fastfetch --format json > "$SYSINFO_FILE.tmp" +fastfetch --config "$FASTFETCH_CONFIG" --format json > "$SYSINFO_FILE.tmp" mv "$SYSINFO_FILE.tmp" "$SYSINFO_FILE" echo "Written to $SYSINFO_FILE" diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index b7cf164..df19fe1 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: Minefetch -version: '1.2.0' +version: '1.2.1' main: uk.ewancroft.minefetch.MinefetchPlugin api-version: '1.21' description: Displays host and container system information in-game.