.desktop経由のフルパスを持つ変数の外部ファイル名に格納されているBashスクリプト

.desktop経由のフルパスを持つ変数の外部ファイル名に格納されているBashスクリプト

まあ、私は私がやりたいことをやり直そうとします。何度もすみません。この質問をより客観的にする方法がわかりません。

「Xfce Desktop」および「」ファイルで使用するために「mupen64plus」を実行するための最初のスクリプトを作成しています。

mupen64plus.desktop現在のコンテンツ

[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

bashスクリプトのアイデアは次のとおりです。

  1. パスのインポート(スクリプトおよび絶対ディレクトリパス)

  2. たとえば、絶対パスを持つ外部ファイルをインポートしますARCHIVO/media/Inukaze1/N64/mupen64plus.v64/media/Nicolas/Temporal/N64/ROMS/mupen64plus.v64

    なぜなら、mupen64plusをロードするにはファイルの絶対パスが必要なからです。そのため、パスがまったく異なる可能性があるため、絶対パスを変数に保存する必要があります。 (ARCHIVOこの場合は変数を呼び出すことをお勧めします。)

    その後、値が1つのファイルの場合は、ARCHIVO複数のファイルを選択しても構いません。 (誤って別のROMを使用してmupen64plusの複数のインスタンスを開いたくありません。)

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

    ''この名前を使用する理由は、Bike Race ’98特殊文字を使用すると問題が発生する可能性があるためです""

  3. 私はいくつかのスクリプトを書いたが、たくさん書いた。特定のタイトルに必要な内容を作成したからです。

  4. .desktopファイルからmupen64plusを実行し、「次のプログラムで開く」を使って「N64 ROM」をロードして、ROMを正しく起動してください。

    nesworldやn64squidなどのウェブサイトで、いくつかのホームブループログラムやデモを見つけることができます。

さて、「本文は30000文字に制限されています。41290を入力しました」というメッセージが表示されるので、スクリプトの内容を投稿に入れることができます。

私の現在のmupen64plus.gebスクリプトコンテンツ(スペイン語の単語がたくさんあるように、私の母国語はスペイン語です)

このURLでスクリプトを表示 - >https://controlc.com/f3d25176

ベストアンサー1

デスクトップファイルを介してスクリプトを実行するときに何が起こるのかを理解しようとするには、ファイルを新しく作成しました。

1つ目は、次の内容で/home/inukaze/.local/share/applications/mupen64plus_test.desktopを作成することです。

[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

2番目は「/media/Compartido/Lignux/Videojuegos/Emulador/Nintendo/64/mupen64plus/portable/mupen64plus_test.geb」で、内容は次のとおりです。

#!/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

親スクリプトまたはデスクトップファイルを介して「子」スクリプトを実行しましたが、親またはデスクトップファイルの変数がサブスクリプトに転送されないことを確認しました。これがうまくいくように修正する必要がある問題だと思います。必要です。 。

端末で次のコマンドを使用すると、

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

出力は次のとおりです

親スクリプトから:

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

スクリプトから

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

親スクリプトから

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

mupen64plusを正しく起動するには、サブスクリプトが必要で、親スクリプトのromfileへの絶対パスを使用するromファイルが必要です。

さて、「Thunar」で「Open with」を使って実行すると、出力は次のようになります。

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

おすすめ記事