App commands and --ha-remove (iteration 2, step 6)

The platform accepts app commands (D43): flags that get a
QCoreApplication like the manifest commands and run prepare() and then
the new hook runCommand(). The app's --ha-remove clears the device's
retained topics, so HA deletes the device; uninstall.sh runs it after
stopping the app and before unregistering from SteamVR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-06 16:32:51 +02:00
co-authored by Claude Opus 5.5
parent 148ae663cf
commit 0bdcaddcd5
12 changed files with 219 additions and 47 deletions
+9 -3
View File
@@ -64,9 +64,14 @@ EOF
cat > "$out/uninstall.sh" <<EOF
#!/bin/sh
# Unregisters $name from SteamVR and stops it. The folder can be deleted afterwards.
# Stops $name, removes its device from Home Assistant (clears its retained MQTT
# topics) and unregisters it from SteamVR. The folder can be deleted afterwards.
cd "\$(dirname "\$0")" || exit 1
pkill -f "/bin/$exe( |\\$)" 2>/dev/null
mkdir -p logs
# Stopped first, so it can't publish itself again; the broker sends its last will at once.
pkill -f "/bin/$exe( |\\$)" 2>/dev/null && sleep 1
./bin/$exe --ha-remove --log-file logs/install.log ||
echo "Could not remove the device from Home Assistant (see logs/install.log); unregistering anyway." >&2
exec ./bin/$exe --uninstall-manifest --log-file logs/install.log
EOF
chmod +x "$out/install.sh" "$out/uninstall.sh"
@@ -92,7 +97,8 @@ chmod +x "$out/install.sh" "$out/uninstall.sh"
echo "Install / update: ./install.sh (SteamVR must be running)"
echo " SteamVR remembers this folder's location: after moving it,"
echo " run ./install.sh again."
echo "Uninstall: ./uninstall.sh"
echo "Uninstall: ./uninstall.sh (also removes the device from Home Assistant;"
echo " needs the settings file and the MQTT broker)"
echo "Logs: logs/$exe.log (the app), logs/install.log (install.sh);"
echo " run ./bin/$exe --help for options"
echo