Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

[SCRIPT] RetroPie Shell Script Boilerplate



  • @hiulit OMFG! I was thinking about making the same thing but was a bit unmotivated to start it from scratch. Now you started it... such a relief! :D

    After writing all those scripts here and there for the RetroPie community I think I have something to share. I hope to find some time to contribute on your repo.

    Thanks for bringing this up!



  • @cyperghost I'm glad you like! :D
    I like to use config files because it makes the script more 'user-friendly' in my opinion. Feel free to contribute to the repo if you find a better way of handling config files (setting and getting values)



  • @meleu Awesome! I'm already waiting for your contributions! And any other person who'd like to contribute too.
    Together we can come up with a nice and useful boilerplate :)



  • @hiulit I think the comments are kinda wordy. Would you mind if I change the style, trying to reduce the text a bit?



  • @meleu Yeah, sure, no problem! Go for it!



  • @hiulit PR submitted.



  • @meleu Thanks! PR commented ;)



  • I've updated the RetroPie Shell Script Boilerplate:

    UPDATE 1:

    • Merged #2 from @meleu .
    • Added check_dependencies().
    • Added reset_config() to use it in conjunction with set_config() and get_config().
    • Added --version (because I think everyone should use it :P)
    • Added 2 ways to find /home.
    • Added more useful global variables.

    These changes are also reflected in the first comment.

    Coming soon... dialog functions!! Again, thanks to @meleu ;)



  • @hiulit Some additional functions

    # This will determine of savestate directory = config
    # This is part of hiuilits Boilerplate script, with small modification
    # if '~' is detected then expand full homepath
    function get_config() {
        local config
        config="$(grep -Po "(?<=^$1 = ).*" "$CONFIG_FILE")"
        config="${config%\"}"
        config="${config#\"}"
        # [[ ${config:0:1} = "~" ]] && config="${config#??}" && config=~/"$config" # Expand homepath
        # [[ -z ${config##*/} ]] && config="${config%?}" # Sanitize pathes if last character is a /
        # [[ ${config:0:1} != "/" ]] && config="annother value because it is likely no path"
        echo "$config"
    }
    
    # This will determine which script is curently running
    # Is it 'runcommand-onend.sh' or 'runcommand-onstart.sh'
    # It will extract 'end' or 'start' ... Usefull if you need to know which runcommand called the script
    function get_runcommand() {
       local i
       local file_array=("runcommand-onend.sh" "runcommand-onstart.sh")
       for i in "${file_array[@]}"
       do
          [[ $(pgrep -f "$i") ]] && i="${i#*-on}" && echo "${i%.*}"
       done
    }
    
    # Determining file ages
    function file_age() {
        echo "$(date +%s -r "$1")"
    }
    


  • @cyperghost Hey, thanks! I'll take a look at them ;)



Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.