RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    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

    XINIT and ;

    Scheduled Pinned Locked Moved Help and Support
    script modulexinit
    12 Posts 4 Posters 2.0k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      sleve_mcdichael @YFZdude
      last edited by

      @YFZdude I tried putting parentheses both around everything, and inside the outermost quotes. Results were different each time but neither was correct.

      pi@retropie:~ $ echo -e ("\nExecuting (via xinit): "pushd /home/pi/RetroPie/roms/ports/sorr; cp /dev/shm/retropie_xinitrc ~; /opt/retropie/ports/sorr/bgdi-333 "./SorR.dat"; popd"\n")
      -bash: syntax error near unexpected token `('
      pi@retropie:~ $ echo -e "(\nExecuting (via xinit): "pushd /home/pi/RetroPie/roms/ports/sorr; cp /dev/shm/retropie_xinitrc ~; /opt/retropie/ports/sorr/bgdi-333 "./SorR.dat"; popd"\n)"
      (
      Executing (via xinit): pushd /home/pi/RetroPie/roms/ports/sorr
      cp: cannot stat '/dev/shm/retropie_xinitrc': No such file or directory
      ./SorR.dat: doesn't exist or isn't version 7 DCB compatible
      -bash: popd\n): command not found
      pi@retropie:~ $
      
      BuZzB YFZdudeY 2 Replies Last reply Reply Quote 0
      • BuZzB
        BuZz administrators @sleve_mcdichael
        last edited by

        @sleve_mcdichael You will need to use a launch script if you need to do that when using XINIT:

        To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

        1 Reply Last reply Reply Quote 0
        • YFZdudeY
          YFZdude @sleve_mcdichael
          last edited by

          @sleve_mcdichael
          After thinking about it and playing with a test command I remembered the trick.

          You need to escape the ; characters with a \ before each one so it will treat them as text instead of the command separator function.

           echo -e this should\; print as \; one line
          
          S 1 Reply Last reply Reply Quote 0
          • S
            sleve_mcdichael @YFZdude
            last edited by sleve_mcdichael

            @YFZdude would that I were merely crafting an echo command whole-cloth, that would be great. Unfortunately, it is generated automatically by whatever is in emulators.cfg; I can't just escape the semicolons in one place but not the other, (I mean, I'm sure someone probably can, but I wouldn't know where to start.)

            @BuZz so something like lr-nxengine does then, yeah? First, I'd do an addPort with just XINIT:<command>, and then overwrite that automatically-generated launch script with a custom one:

                [...]
                addPort "bgdi-333" "sorr" "Streets of Rage Remake" "XINIT:$md_inst/bgdi-333 %ROM%" "./SorR.dat"
                local file="$romdir/ports/Streets of Rage Remake.sh"
                cat > "$file" << _EOF_
            #!/bin/bash
            pushd "$romdir/ports/sorr"
            "$rootdir/supplementary/runcommand/runcommand.sh" 0 _PORT_ "sorr" "./SorR.dat"
            popd
            _EOF_
                chown $user:$user "$file"
                chmod +x "$file"
                [...]
            

            Like that?

            mituM 1 Reply Last reply Reply Quote 0
            • mituM
              mitu Global Moderator @sleve_mcdichael
              last edited by

              @sleve_mcdichael Don't mix runcommand into your launch script.

              S 1 Reply Last reply Reply Quote 0
              • S
                sleve_mcdichael @mitu
                last edited by sleve_mcdichael

                @mitu ...er, why? Literally every launch script in my ports folder uses runcommand:

                pi@retropie:~/RetroPie/roms/ports $ grep *.sh -e runcommand.sh
                am2r.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "droidports" "/home/pi/RetroPie/roms/ports/droidports/am2r_155.apk"
                cavestory.sh:    "/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ cavestory "/home/pi/RetroPie/roms/ports/CaveStory/Doukutsu.exe"
                doom2-htp.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "doom" "/home/pi/RetroPie/roms/ports/doom/htp/DOOM2.WAD"
                doom2-nerve.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "doom" "/home/pi/RetroPie/roms/ports/doom/nerve/DOOM2.WAD"
                doom2-pg.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "doom" "/home/pi/RetroPie/roms/ports/doom/pg/DOOM2.WAD"
                doom2.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "doom" "/home/pi/RetroPie/roms/ports/doom/doom2/DOOM2.WAD"
                doom-jptr.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "doom" "/home/pi/RetroPie/roms/ports/doom/jptr/DOOM.WAD"
                doom-sigil.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "doom" "/home/pi/RetroPie/roms/ports/doom/sigil/DOOM.WAD"
                doom-ultimate.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "doom" "/home/pi/RetroPie/roms/ports/doom/ultimate/DOOM.WAD"
                duke3d.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "duke3d" "-j /home/pi/RetroPie/roms/ports/duke3d/"
                duke-dc.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "duke3d" "-j /home/pi/RetroPie/roms/ports/duke3d -g dc/dukedc.grp"
                duke-nw.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "duke3d" "-j /home/pi/RetroPie/roms/ports/duke3d -g nw/nwinter.grp -x nw/nwinter.con"
                duke-vacation.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "duke3d" "-j /home/pi/RetroPie/roms/ports/duke3d -g vacation/vacation.grp -x vacation/game.con -j /home/pi/RetroPie/roms/ports/duke3d/vacation"
                finaldoom1.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "doom" "/home/pi/RetroPie/roms/ports/doom/finaldoom1/TNT.WAD"
                finaldoom2.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "doom" "/home/pi/RetroPie/roms/ports/doom/finaldoom2/PLUTONIA.WAD"
                freedoom1.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "doom" "/home/pi/RetroPie/roms/ports/doom//freedoom1/FREEDOOM1.WAD"
                freedoom2.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "doom" "/home/pi/RetroPie/roms/ports/doom/freedoom2/FREEDOOM2.WAD"
                hcl.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "hcl" ""
                hurrican.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "hurrican" ""
                maldita.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "droidports" "/home/pi/RetroPie/roms/ports/droidports/Maldita_Castilla_ouya.apk"
                marathon1.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "alephone" "/home/pi/RetroPie/roms/ports/alephone/Marathon/"
                marathon2.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "alephone" "/home/pi/RetroPie/roms/ports/alephone/Marathon 2/"
                marathon3.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "alephone" "/home/pi/RetroPie/roms/ports/alephone/Marathon Infinity/"
                quake-dopa.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "quake" "/home/pi/RetroPie/roms/ports/quake/dopa/pak0.pak"
                quake-hipnotic.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "quake" "/home/pi/RetroPie/roms/ports/quake/hipnotic/pak0.pak"
                quake-rogue.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "quake" "/home/pi/RetroPie/roms/ports/quake/rogue/pak0.pak"
                quake.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "quake" "/home/pi/RetroPie/roms/ports/quake/id1/pak0.pak"sorr.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "sorr" "./SorR.dat"
                supertux.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "supertux" ""
                sw-dragon.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "sw" "-gdragon.zip"
                sw.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "sw" ""
                sw-wt.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "sw" "-gwt.grp"
                wolf3d.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "wolf3d" "/home/pi/RetroPie/roms/ports/wolf3d/vswap.wl6"wolf-sd1.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "wolf3d" "/home/pi/RetroPie/roms/ports/wolf3d/vswap.sd1"
                wolf-sd2.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "wolf3d" "/home/pi/RetroPie/roms/ports/wolf3d/vswap.sd2"
                wolf-sd3.sh:"/opt/retropie/supplementary/runcommand/runcommand.sh" 0 _PORT_ "wolf3d" "/home/pi/RetroPie/roms/ports/wolf3d/vswap.sd3"
                

                I based it on what lr-nxengine.sh does for Cave Story:

                addPort "$md_id" "cavestory" "Cave Story" "$md_inst/nxengine_libretro.so"
                    local file="$romdir/ports/Cave Story.sh"
                    # custom launch script - if the data files are not found, warn the user
                    cat >"$file" << _EOF_
                #!/bin/bash
                if [[ ! -f "$romdir/ports/CaveStory/Doukutsu.exe" ]]; then
                    dialog --no-cancel --pause "$md_help" 22 76 15
                else
                    "$rootdir/supplementary/runcommand/runcommand.sh" 0 _PORT_ cavestory "$romdir/ports/CaveStory/Doukutsu.exe"
                fi
                _EOF_
                    chown $user:$user "$file"
                    chmod +x "$file"
                

                Is this different because of XINIT:, or what do you mean?

                Edit: oh, is that going to "start over" in ~, essentially "undoing" the pushd?

                1 Reply Last reply Reply Quote 0
                • mituM
                  mitu Global Moderator
                  last edited by

                  @sleve_mcdichael said in XINIT and ;:

                  Is this different because of XINIT:, or what do you mean?

                  Your script is called from runcommand, which takes care of XINIT handling, calling runcommand again from your script doesn't makes sense. The script should just start the game.

                  1 Reply Last reply Reply Quote 0
                  • S
                    sleve_mcdichael
                    last edited by sleve_mcdichael

                    @mitu ah, so I'm not overwriting the "launch script" that's inroms like lr-nxengine does, but adding, say, a "buffer" launch script in $md_inst like wolf4sdl or eduke32 do?

                    Something like this then, maybe:

                        [...]
                        addPort "bgdi-333" "sorr" "Streets of Rage Remake" "XINIT:$md_inst/$md_id.sh %ROM%" "./SorR.dat"
                        local file="$md_inst/$md_id.sh"
                        cat > "$file" << _EOF_
                    #!/bin/bash
                    pushd "$romdir/ports/sorr"
                    "$md_inst/bgdi-333" \$*
                    popd
                    _EOF_
                        chown $user:$user "$file"
                        chmod +x "$file"
                        [[ -f "$romdir/ports/$md_id/SorMaker.dat" || "$md_mode" == "remove" ]] && addPort "bgdi-333" "sorr" "SorMaker" "XINIT:$md_inst/$md_id.sh %ROM%" "./SorMaker.dat"
                        [...]
                    

                    Edit: changed the commands a little. Does this work to pass %ROM% as additional arguments? And does that last line work like I think it does?

                    mituM 1 Reply Last reply Reply Quote 0
                    • mituM
                      mitu Global Moderator @sleve_mcdichael
                      last edited by

                      That looks better.

                      Edit: changed the commands a little. Does this work to pass %ROM% as additional arguments?

                      Yes, you'd get it in $1 (1st arg), but I'm not sure if it help or is useful in this case. You can just pass SorR.dat as argument to the starting game script.

                      S 1 Reply Last reply Reply Quote 0
                      • S
                        sleve_mcdichael @mitu
                        last edited by

                        @mitu sorry I made another edit. I want to pass that as the %ROM% parameter so we can make another menu entry for the level editor.

                        1 Reply Last reply Reply Quote 0
                        • S sleve_mcdichael referenced this topic on
                        • First post
                          Last post

                        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.