-1

ok i try to make the most resumed the points i want to do. Sorry for the repetions i don't know how make this question more objectively

The first i am making a script for launch "mupen64plus", is for use with "Xfce Desktop" with the file ""

The mupen64plus.desktop current content

[Desktop Entry]
Version=1.0
Type=Application
Name=Mupen64Plus
GenericName=N64 Emulator
Comment=Nintendo 64 emulator and plugins for Linux, Mac OSX, FreeBSD, and Windows
Exec=xfce4-terminal --hold --execute /usr/bin/bash -c "/media/Compartido/Lignux/Videojuegos/Emulador/Nintendo/64/mupen64plus/portable/mupen64plus.geb" %F
Icon=/media/Compartido/Lignux/Videojuegos/Emulador/Nintendo/64/mupen64plus/portable/.mupen64plus.svg
MimeType=application/x-n64-rom;
Categories=Game;Emulator;
Keywords=Emulator;Nintendo64;Mupen64plus;
;NoDisplay=true

The idea on the bash script is the follow points

  1. Get paths (script & absolute dir path)

  2. Get external file with absolute path for example and save it on a variable called ARCHIVO - /media/Inukaze1/N64/mupen64plus.v64 or /media/Nicolas/Temporal/N64/ROMS/mupen64plus.v64

    Because mupen64plus ever needs the absolute path of file to load it. for that reason because the path can be completely different i need store the absolute path on a variable (i prefer call the variable ARCHIVO for this case)

    Then the value of ARCHIVO just ever be one file, does not matter if i select multiples files (i don't want open accidentally multiple mupen64plus instances with different roms) like

     ARCHIVO='/media/samba/Inukaze/ROMS/Nintendo 64/Demos/Nintro 64'
     # or
     ARCHIVO='/mnt/cifs/Temp/N64Homebrews/Bike Race ’98'
    

    The reason for use '' is for names like Bike Race ’98, that special character can be a problem if i use "".

  3. I already have some of script wrote, but is a lot because i ever put some things i need for specific title.

  4. Start mupen64plus via .desktop file using "Open with" to load "N64 ROM" and start the rom correctly.

    You can find some homebrew & demos on site like nesworld and/or n64squid

Well i can put my script content on the post because appears the message "Body is limited to 30000 characters; you entered 41290."

My current mupen64plus.geb script content (my native lang is spanish because of that you can see a lot of spanish words)

View the script on this url -> https://controlc.com/f3d25176

3
  • 2
    And what's the question? What problem are you having? I think your script could be pasted here if you reduce the repetition and use more loops, remove all that extra whitespace (seriously those rm ... ln lines look nefarious, like you're hoping to hide the ln lines by having them lie beyond the viewport).
    – muru
    Jul 18 at 4:03
  • The question is how i can make the desktop file when use the bash script the bash script save the absolute path of file when i click "open with" "mupen64plus" and that open correctly the rom file i select. After i can test i can run any rom without problem i optimice my code. the ln and rms is because i need specific configurations for each title and for make mupen64plus run on any distro like a "portable"
    – Inukaze
    Jul 18 at 10:50
  • Please don't add "solved" to the question
    – muru
    Jul 20 at 12:59

1 Answer 1

0

i had write too new files, just to try to understand what is happend when i run the script via desktop file

The first new /home/inukaze/.local/share/applications/mupen64plus_test.desktop, the content is

[Desktop Entry]
Version=1.0
Type=Application
Name=Mupen64Plus TEST
GenericName=N64 Emulator
Comment=Nintendo 64 emulator and plugins for Linux, Mac OSX, FreeBSD, and Windows
Exec=xfce4-terminal --hold --execute /usr/bin/bash -c "/media/Compartido/Lignux/Videojuegos/Emulador/Nintendo/64/mupen64plus/portable/mupen64plus_test.geb" %k
Icon=/media/Compartido/Lignux/Videojuegos/Emulador/Nintendo/64/mupen64plus/portable/.mupen64plus.svg
MimeType=application/x-n64-rom;
Categories=Game;Emulator;
Keywords=Emulator;Nintendo64;Mupen64plus;
;NoDisplay=true

The second is "/media/Compartido/Lignux/Videojuegos/Emulador/Nintendo/64/mupen64plus/portable/mupen64plus_test.geb" the content is :

#!/usr/bin/env bash

#Determine in which directory i am located :
SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT")
cd "$SCRIPTPATH"

#Get File Extension :
EXTENSION=$(echo "$1" | awk -F '.' '{print $NF}')

ARCH=$(uname -m)
case "$ARCH" in
    x86)    ARCH="x32"                      ;;
    i?86)   ARCH="x32"                      ;;
    amd64)  ARCH="x64"                      ;;
    x86_64) ARCH="x64"                      ;;
    * ) echo    "Your Architecture '$ARCH' -> Is not supported."    ;;
esac

ROMFILE="%k"    #I suppose i need redirect .desktop file %k to this bash variable called $ROMFILE
                            #To storage the absolute path of rom file. but is just an idea
                            
if [ "$ARCH" == "x64" ]
then
        export LD_LIBRARY_PATH="./.libs/64Bits":$LD_LIBRARY_PATH
        EJECUTABLE=".mupen64plus.x64"
fi

if [ "$ARCH" == "x32" ]
then
        export LD_LIBRARY_PATH="./.libs/32Bits":$LD_LIBRARY_PATH
        EJECUTABLE=".mupen64plus.x32"
fi

if [ -z "$1" ]
then
        echo ""
        echo -e "First Argument is Empty Variable\n"
        echo ""
else
        echo ""
        echo -e "First Argument is a File ; Check md5sum"
        MD5=$(md5sum "$1"| tr a-z A-Z | awk '{print $1}')
        echo ""
        echo 'Inside "if [ -z "$1"] else '
        echo "Reveal variable content : "
        echo '"$@"' = "'"$@"'"
        echo '"$*"' = "'"$*"'"
        echo '"$1"' = "'"$1"'"
        echo '"$2"' = "'"$2"'"
        echo '"%k"' = %k
        echo ""
        echo "Now First Try to run mupen64plus : without another script"
        ./.mupen64plus.x64 --corelib "./.libs/64Bits/libmupen64plus.so.2.0.0" --datadir "." --configdir "." "$@"
        echo "This work"
        echo "Now Second Try to run mupen64plus : via another script"
        bash -c "'"/media/Compartido/Lignux/Videojuegos/Emulador/Nintendo/64/mupen64plus/portable/mupen64plus.geb"'" < "$1"
        echo "This not work"
fi

echo -e ""
echo "i need when mupen64plus script run for any folder store the absolute path of rom i want to run"
echo "For example : "
echo -e ""
echo '"/media/Compartido/Lignux/Videojuegos/Emulador/Nintendo/64/mupen64plus/portable/mupen64plus.geb"' "'"/media/Nicolas/Temporal/ROMS/N64/Mupen64Plus.v64"'"
echo -e ""
echo "The first is absolute path my script"
echo "and the second is the absolute path of romfile"
echo "on another very diferent directory"
echo -e ""
echo "i don't have idea how redirect absolute path of romfile from .desktop file"
echo "to bash variable before the mupen64plus execute"

exit 0

i notice is i ran a "child" script via parent script or from desktop file, the variables from the parent or desktop file are not transfered to child script, i think this is the problem i should solve for make it work i need it.

if i use the follow commands on a terminal

cd /tmp
"/media/Compartido/Lignux/Videojuegos/Emulador/Nintendo/64/mupen64plus/portable/mupen64plus_test.geb" '/media/Nicolas/Temporal/ROMS/N64/Mupen64Plus.v64'

The output(s) are :

From Parent script :

First Argument is a File ; Check md5sum

Inside "if [ -z "$1"] else 
Reveal variable content : 
"$@" = '/media/Nicolas/Temporal/ROMS/N64/Mupen64Plus.v64'
"$*" = '/media/Nicolas/Temporal/ROMS/N64/Mupen64Plus.v64'
"$1" = '/media/Nicolas/Temporal/ROMS/N64/Mupen64Plus.v64'
"$2" = ''
"%k" = %k

Now First Try to run mupen64plus : without another script
 __  __                         __   _  _   ____  _             
|  \/  |_   _ _ __   ___ _ __  / /_ | || | |  _ \| |_   _ ___ 
| |\/| | | | | '_ \ / _ \ '_ \| '_ \| || |_| |_) | | | | / __|  
| |  | | |_| | |_) |  __/ | | | (_) |__   _|  __/| | |_| \__ \  
|_|  |_|\__,_| .__/ \___|_| |_|\___/   |_| |_|   |_|\__,_|___/  
             |_|         https://mupen64plus.org/               
Mupen64Plus Console User-Interface Version 2.5.9

UI-Console: attached to core library 'Mupen64Plus Core' version 2.5.9
UI-Console:             Includes support for Dynamic Recompiler.
Core: Using full mem base
Core: Goodname: Mupen64Plus Demo by Marshallh (GPL)
Core: Name: Mupen64Plus         
Core: MD5: DBF04773EC2B8ADF8A94DB7E3E461138
Core: CRC: DDBA4DE5 B107004A
Core: Imagetype: .v64 (byteswapped)
Core: Rom size: 1048576 bytes (or 1 Mb or 8 Megabits)
Core: Version: 1444
Core: Manufacturer: 0
Core: Country: Demo
UI-Console Status: Cheat codes disabled.
UI-Console: using Video plugin: 'Glide64mk2 Video Plugin' v2.5.9
UI-Console: using Audio plugin: 'Mupen64Plus SDL Audio Plugin' v2.5.9
Input: Using auto-config file at: './InputAutoCfg.ini'
Input: Using auto-config file at: './InputAutoCfg.ini'
UI-Console: using Input plugin: 'Mupen64Plus SDL Input Plugin' v2.5.9
UI-Console: using RSP plugin: 'Hacktarux/Azimer High-Level Emulation RSP Plugin' v2.5.9
Video: opening ./Glide64mk2.ini

Video: 3DNOW! detected.

Core: input plugin did not specify a render callback; there will be no on screen display by the input plugin.
Input: 2 SDL joysticks were found.
Input: N64 Controller #1: Using manual config with no SDL joystick (keyboard/mouse only)
Input: Using auto-config file at: './InputAutoCfg.ini'
Input: N64 Controller #2: Using auto-config with SDL joystick 0 ('Twin USB Joystick')
Input: Using auto-config file at: './InputAutoCfg.ini'
Input: N64 Controller #3: Using auto-config with SDL joystick 1 ('Twin USB Joystick')
Input: 3 controller(s) found, 3 plugged in and usable in the emulator
Input Warning: Couldn't open rumble support for joystick #1
Input: Rumble activated on N64 joystick #2
Input: Rumble activated on N64 joystick #3
Input Warning: Couldn't open rumble support for joystick #4
Input: Mupen64Plus SDL Input Plugin version 2.5.9 initialized.
RSP Error: Can't load library: mupen64plus-rsp-z64.so
Core: Using video capture backend: dummy
Core: Game controller 0 (Standard controller) has a Memory pak plugged in
Core: Game controller 1 (Standard controller) has a Memory pak plugged in
Core: Game controller 2 (Standard controller) has a Memory pak plugged in
Core: Game controller 3 (Standard controller) has a Memory pak plugged in
Core: Using CIC type X102
Video: Using TEXUMA extension.

&ConfigOpenSection is 0x7fcfd3f7e688
(II) Setting video mode 1058x885...
Core: Setting video mode: 1058x885
Congratulations, you have 4 auxilliary buffers, we'll use them wisely !
packed pixels extension used
NPOT extension used
use_fbo 1
Video: InitCombine() 
Video: extensions 
Video: initialized.
Video: 

Audio: Using resampler speex
Audio: Initializing SDL audio subsystem...
ALSA lib pcm_direct.c:1568:(_snd_pcm_direct_get_slave_ipc_offset) Invalid value for card
Input Warning: Couldn't open rumble support for joystick #1
Input: Rumble activated on N64 joystick #2
Input: Rumble activated on N64 joystick #3
Input Warning: Couldn't open rumble support for joystick #4
Core: Initializing 4 RDRAM modules for a total of 8 MB
Core: Starting R4300 emulator: Dynamic Recompiler
Core Status: Stopping emulation.
Core: R4300 emulator finished.
Core Status: Rom closed.
This work

Now Second Try to run mupen64plus : via another script

From script child

Autor ----------------> Inukaze ( Venezuela )
Sitio ----------------> https://goo.gl/ij6WqW
Correo-E -------------> [email protected]
Licencia -------------> GPL 2

******* Inicio : Acerca de este Guión ********

  Yo intento escribir guiones compatibles con
   Sistemas operativos Unix & POSIX , y otros
   Sistemas operativos que soporten bash

  Este archivo es un guion sencillo para
  Iniciar "mupen64plus"
  [Emulador de Nintendo 64]

******** Fin : Acerca de este Guión **********


Antes del -z "$@" de 64 Bits
"$@" = ''
"$*" = ''
"$1" = ''
"$2" = ''
"%k" = '%k'
Despues del -z "$@" de 64 Bits
"$@" = ''
"$*" = ''
"$1" = ''
"$2" = ''
"%k" = '%k'
 __  __                         __   _  _   ____  _             
|  \/  |_   _ _ __   ___ _ __  / /_ | || | |  _ \| |_   _ ___ 
| |\/| | | | | '_ \ / _ \ '_ \| '_ \| || |_| |_) | | | | / __|  
| |  | | |_| | |_) |  __/ | | | (_) |__   _|  __/| | |_| \__ \  
|_|  |_|\__,_| .__/ \___|_| |_|\___/   |_| |_|   |_|\__,_|___/  
             |_|         https://mupen64plus.org/               
Mupen64Plus Console User-Interface Version 2.5.9

UI-Console: attached to core library 'Mupen64Plus Core' version 2.5.9
UI-Console:             Includes support for Dynamic Recompiler.
Core: Using full mem base
UI-Console Error: no ROM filepath given

From Parent Script

This not work

i need when mupen64plus script run for any folder store the absolute path of rom i want to run
For example : 

"/media/Compartido/Lignux/Videojuegos/Emulador/Nintendo/64/mupen64plus/portable/mupen64plus.geb" '/media/Nicolas/Temporal/ROMS/N64/Mupen64Plus.v64'

The first is absolute path my script
and the second is the absolute path of romfile
on another very diferent directory

i don't have idea how redirect absolute path of romfile from .desktop file
to bash variable before the mupen64plus execute

i need the child script use the romfile absolute path from parent script for launch mupen64plus with rom file correctly

and well if i ran using "Open with" from "Thunar" the output is the follow

First Argument is Empty Variable



i need when mupen64plus script run for any folder store the absolute path of rom i want to run
For example : 

"/media/Compartido/Lignux/Videojuegos/Emulador/Nintendo/64/mupen64plus/portable/mupen64plus.geb" '/media/Nicolas/Temporal/ROMS/N64/Mupen64Plus.v64'

The first is absolute path my script
and the second is the absolute path of romfile
on another very diferent directory

i don't have idea how redirect absolute path of romfile from .desktop file
to bash variable before the mupen64plus execute

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .