Files
recalbox-savesync/pub_event[rungame,endgame](sync).ash
2026-02-27 14:21:33 -06:00

27 lines
605 B
Plaintext

#!/bin/ash
# shellcheck shell=ash
#
#
eventfile="/tmp/es_state.inf"
# 1. Check if the file exists and is not empty
if [ ! -s "$eventfile" ]; then
echo "Error: $eventfile is missing or empty."
exit 1
fi
# 2. Read the payload safely
PAYLOAD=$(cat "$eventfile")
# 3. Publish (using double quotes to handle spaces/newlines in the file)
mosquitto_pub -h 127.0.0.1 -p 1883 -t /Recalbox/EmulationStation/Event -m "$PAYLOAD"
# 4. Optional: check if the publish succeeded
if [ $? -eq 0 ]; then
echo "Successfully published event."
else
echo "Failed to connect to mosquitto broker."
fi
sleep 4