#!/bin/bash # Spawn Service Script by cyperghost (second life) # This is a crude example, but shows the ability of the new services switch="RETROFLAG RETROFLAG_ADV" #Add here more values path="/userdata/system/services" # First argument for condition: start=service switched on case ${1} in start) # Create single scripts per echo command and place them to /services # The test start inside the sub-services is needed to set the system.power.switch parameter only if service is ticked for i in ${switch}; do echo "[ \${1} == start ] && batocera-settings-set system.power.switch ${i}" > ${path}/PI_${i} done # Check and set indicator to on if a proper value is found in batocera.conf, if there is no value then indicator is setted to off active_service=$(batocera-settings-get system.power.switch) if [ -n ${active_service} ]; then batocera-services enable PI_${active_service} fi ;; stop) #Remove all entries from filesystem and in batocera.conf (done through batocera-services) for i in ${switch}; do rm -f ${path}/PI_${i} batocera-services disable PI_${i} done ;; esac