Files
venus/dbus-generator-ramp/install_gui.sh
dev 9756538f16 Initial commit: Venus OS boat addons monorepo
Organizes 11 projects for Cerbo GX/Venus OS into a single repository:
- axiom-nmea: Raymarine LightHouse protocol decoder
- dbus-generator-ramp: Generator current ramp controller
- dbus-lightning: Blitzortung lightning monitor
- dbus-meteoblue-forecast: Meteoblue weather forecast
- dbus-no-foreign-land: noforeignland.com tracking
- dbus-tides: Tide prediction from depth + harmonics
- dbus-vrm-history: VRM cloud history proxy
- dbus-windy-station: Windy.com weather upload
- mfd-custom-app: MFD app deployment package
- venus-html5-app: Custom Victron HTML5 app fork
- watermaker: Watermaker PLC control UI

Adds root README, .gitignore, project template, and per-project
.gitignore files. Sensitive config files excluded via .gitignore
with .example templates provided.

Made-with: Cursor
2026-03-16 17:04:16 +00:00

225 lines
6.6 KiB
Bash
Executable File

#!/bin/bash
#
# Install GUI modifications for Generator Ramp Controller
#
# This script:
# 1. Copies PageSettingsGeneratorRamp.qml to the GUI directory
# 2. Patches PageSettingsGenerator.qml to add our menu item
# 3. Restarts the GUI
#
# Note: These changes will be lost on firmware update.
# Run this script again after updating firmware.
#
# Usage:
# ./install_gui.sh # Install GUI modifications
# ./install_gui.sh --remove # Remove GUI modifications
#
set -e
QML_DIR="/opt/victronenergy/gui/qml"
INSTALL_DIR="/data/dbus-generator-ramp"
BACKUP_DIR="/data/dbus-generator-ramp/backup"
# The menu entry to add to PageSettingsGenerator.qml
MENU_ENTRY='
MbSubMenu {
description: qsTr("Dynamic current ramp")
subpage:
Component {
PageSettingsGeneratorRamp {
title: qsTr("Dynamic current ramp")
}
}
}'
# Marker to identify our modification
MARKER="<!-- GeneratorRamp addon -->"
install_gui() {
echo "=================================================="
echo "Installing GUI modifications..."
echo "=================================================="
# Check if our service is installed
if [ ! -f "$INSTALL_DIR/dbus-generator-ramp.py" ]; then
echo "ERROR: Main service not installed. Run install.sh first."
exit 1
fi
# Check if QML directory exists
if [ ! -d "$QML_DIR" ]; then
echo "ERROR: GUI directory not found: $QML_DIR"
exit 1
fi
# Create backup directory
mkdir -p "$BACKUP_DIR"
# Step 1: Copy our QML file
echo "1. Installing PageSettingsGeneratorRamp.qml..."
if [ -f "$INSTALL_DIR/qml/PageSettingsGeneratorRamp.qml" ]; then
cp "$INSTALL_DIR/qml/PageSettingsGeneratorRamp.qml" "$QML_DIR/"
echo " Copied to $QML_DIR/"
else
echo "ERROR: PageSettingsGeneratorRamp.qml not found"
exit 1
fi
# Step 2: Backup and patch PageSettingsGenerator.qml
echo "2. Patching PageSettingsGenerator.qml..."
GENERATOR_QML="$QML_DIR/PageSettingsGenerator.qml"
# Check if already patched
if grep -q "PageSettingsGeneratorRamp" "$GENERATOR_QML"; then
echo " Already patched, skipping..."
else
# Create backup
if [ ! -f "$BACKUP_DIR/PageSettingsGenerator.qml.orig" ]; then
cp "$GENERATOR_QML" "$BACKUP_DIR/PageSettingsGenerator.qml.orig"
echo " Backup saved to $BACKUP_DIR/"
fi
# Find the line with "Warm-up & cool-down" MbSubMenu and insert our menu after it
# We'll insert after the closing brace of that MbSubMenu block
# Create a Python script to do the patching (more reliable than sed for multi-line)
python3 << 'PYTHON_SCRIPT'
import re
qml_file = "/opt/victronenergy/gui/qml/PageSettingsGenerator.qml"
with open(qml_file, 'r') as f:
content = f.read()
# Check if already patched
if 'PageSettingsGeneratorRamp' in content:
print("Already patched")
exit(0)
# Find the "Warm-up & cool-down" MbSubMenu block and insert after it
# We look for the pattern and insert our menu item after the closing brace
menu_entry = '''
MbSubMenu {
description: qsTr("Dynamic current ramp")
subpage:
Component {
PageSettingsGeneratorRamp {
title: qsTr("Dynamic current ramp")
}
}
}'''
# Find the warm-up submenu and add our entry after it
# The warm-up submenu ends with a closing brace followed by the Detect generator switch
pattern = r'(PageSettingsGeneratorWarmup \{[^}]*\}[^}]*\}[^}]*\})'
def insert_menu(match):
return match.group(1) + menu_entry
new_content = re.sub(pattern, insert_menu, content, count=1)
if new_content == content:
# Alternative: insert before the "Detect generator at AC input" switch
pattern2 = r"(\n\t\tMbSwitch \{\n\t\t\tproperty bool generatorIsSet)"
new_content = re.sub(pattern2, menu_entry + r'\1', content, count=1)
if new_content == content:
print("ERROR: Could not find insertion point")
exit(1)
with open(qml_file, 'w') as f:
f.write(new_content)
print("Patched successfully")
PYTHON_SCRIPT
echo " Patch applied"
fi
# Step 3: Add to rc.local for persistence
echo "3. Setting up persistence in rc.local..."
RC_LOCAL="/data/rc.local"
if ! grep -q "install_gui.sh" "$RC_LOCAL" 2>/dev/null; then
echo "" >> "$RC_LOCAL"
echo "# Restore Generator Ramp GUI modifications after firmware update" >> "$RC_LOCAL"
echo "if [ -f /data/dbus-generator-ramp/install_gui.sh ]; then" >> "$RC_LOCAL"
echo " /data/dbus-generator-ramp/install_gui.sh 2>/dev/null &" >> "$RC_LOCAL"
echo "fi" >> "$RC_LOCAL"
echo " Added to rc.local for automatic restoration"
else
echo " Already in rc.local"
fi
# Step 4: Restart GUI
echo "4. Restarting GUI..."
if [ -d /service/start-gui ]; then
svc -t /service/start-gui
sleep 2
elif [ -d /service/gui ]; then
svc -t /service/gui
sleep 2
else
echo " Note: GUI service not found. Restart manually or reboot."
fi
echo ""
echo "=================================================="
echo "GUI installation complete!"
echo "=================================================="
echo ""
echo "The 'Dynamic current ramp' option should now appear in:"
echo " Settings -> Generator start/stop -> Settings -> Dynamic current ramp"
echo ""
echo "Note: Run this script again after firmware updates."
echo ""
}
remove_gui() {
echo "=================================================="
echo "Removing GUI modifications..."
echo "=================================================="
# Remove our QML file
if [ -f "$QML_DIR/PageSettingsGeneratorRamp.qml" ]; then
rm "$QML_DIR/PageSettingsGeneratorRamp.qml"
echo "1. Removed PageSettingsGeneratorRamp.qml"
fi
# Restore original PageSettingsGenerator.qml
if [ -f "$BACKUP_DIR/PageSettingsGenerator.qml.orig" ]; then
cp "$BACKUP_DIR/PageSettingsGenerator.qml.orig" "$QML_DIR/PageSettingsGenerator.qml"
echo "2. Restored original PageSettingsGenerator.qml"
else
echo "2. No backup found, manual cleanup may be needed"
fi
# Restart GUI
echo "3. Restarting GUI..."
if [ -d /service/start-gui ]; then
svc -t /service/start-gui
sleep 2
elif [ -d /service/gui ]; then
svc -t /service/gui
sleep 2
else
echo " Note: GUI service not found. Restart manually or reboot."
fi
echo ""
echo "GUI modifications removed."
echo ""
}
# Main
case "$1" in
--remove)
remove_gui
;;
*)
install_gui
;;
esac