简体   繁体   English

如何使用数组值作为启动参数?

[英]How to use array values for launch parameters?

i am trying to write a script for launch Steam Native For Windows, via PlayOnLinux. 我正在尝试编写一个脚本,以通过PlayOnLinux启动Windows的Steam Native。 Just with videogames have a Microsoft Windows Binary Executable only. 仅与视频游戏一起才具有Microsoft Windows Binary Executable。

Reading the "ID" from a list, is the ID its not in the list then launch Steam native for GNU/Linux. 从列表中读取“ ID”是其不在列表中的ID,然后启动适用于GNU / Linux的Steam本机。

The idea of this script is for use it with a Web Browser for example : Mozilla Firefox using the "steam://" protocol. 该脚本的想法是与Web浏览器一起使用,例如:使用“ steam://”协议的Mozilla Firefox。

i put my script here (i am from Venezuela, and the script is make it on Spanish, if its possible, please don't translate the variables) : 我把我的脚本放在这里(我来自委内瑞拉,脚本是用西班牙语制作的,如果可能的话,请不要翻译变量):

#!/usr/bin/env bash

echo '
Autor ----------------> Inukaze ( Venezuela )
Licensia -------------> GPL 2

******* Inicio : Acerca de este Script ********

 Este Mini-Script es para poder iniciar Steam
 Para Windows, desde un Navegador Web Nativo
 para Liñux.

 La idea y la funcion es para facilitar la 
 Instalación de varios Videojuegos que no
 poseen una version nativa para Liñux

 Iniciando el Steam que tengas en el prefijo
 "Steam" dentro de "PlayOnLinux" e iniciando
 y encolando la descarga de (los) titulo(s)
 que hayas hecho clic en el navegador

******** Fin : Acerca de este Script **********
'

# Obtener el Nombre del Nucleo
Nucleo=$(uname -s)
case "$Nucleo" in
    Linux)      Nucleo="linux"                      ;;
    FreeBSD)    Nucleo="kfreebsd"                   ;;
    GNU/kFreeBSD)   Nucleo="kfreebsd"                   ;;
    * ) echo "Tu Sistema Operativo -> NO ESTA SOPORTADO"            ;;
esac

# Obtener la ARQUITECTURA
ARQUITECTURA=$(uname -m)
case "$ARQUITECTURA" in
    x86)    ARQUITECTURA="x86"                      ;;
    i?86)   ARQUITECTURA="x86"                      ;;
    amd64)  ARQUITECTURA="amd64"                        ;;
    x86_64) ARQUITECTURA="amd64"                        ;;
    * ) echo    "Tú Arquitectura : '$ARQUITECTURA' : -> IT NOT SUPPORTED."  ;;
esac

# Comprobrar que (No/)Existen los archivos y rutas, antes de proceder
if test -d "$HOME/.PlayOnLinux/wineprefix/Steam"
    then
    echo
            if test -f "$HOME/.PlayOnLinux/wineprefix/Steam/drive_c/Program Files/Steam/steam.exe"
            then
                echo "Encontrado ejecutable de Steam en el prefijo predeterminado"
            fi

            if test -d "$HOME/.PlayOnLinux/wineprefix/Steam/drive_c/Program Files/Steam/steamapps/common"
            then
                echo "Encontrada Carpeta Comun de Steam"
            fi
    else
        echo "Steam no esta instalado en el Prefijo Predeterminado"
        xmessage -timeout 3 "Steam no esta instalado en el Prefijo Predeterminado"
        exit 1
fi

if test -f "$HOME/.PlayOnLinux/wineprefix/Steam/playonlinux.cfg"
    then
    # Obtener la version de WINE y su arquitectura del Prefijo Steam dentro de PlayOnLinux ;
    VERSION_WINE=$(cat "$HOME/.PlayOnLinux/wineprefix/Steam/playonlinux.cfg" | grep VERSION= | sed 's/VERSION=//g')
    ARQUITECTURA_WINE=$(cat "$HOME/.PlayOnLinux/wineprefix/Steam/playonlinux.cfg" | grep ARCH= | sed 's/ARCH=//g')
    else
        echo "Steam no esta instalado en el Prefijo Predeterminado"
        xmessage -timeout 3 "Steam no esta instalado en el Prefijo Predeterminado"
        exit 1
fi

# Configurar Variables de Entornos, Rutas e Iniciar Steam para Windows :
PATH="$HOME/.PlayOnLinux/wine/$ARQUITECTURA-$ARQUITECTURA_WINE/$VERSION_WINE/bin:$PATH"
export WINESERVER="$HOME/.PlayOnLinux/wine/$Nucleo-$ARQUITECTURA_WINE/$VERSION_WINE/bin/wineserver"
export WINELOADER="$HOME/.PlayOnLinux/wine/$Nucleo-$ARQUITECTURA_WINE/$VERSION_WINE/bin/wine"
export WINEDLLPATH="$HOME/.PlayOnLinux/wine/$Nucleo-$ARQUITECTURA_WINE/$VERSION_WINE/lib"
export WINEPREFIX="$HOME/.PlayOnLinux/wineprefix/Steam"
export WINEDEBUG=-all
cd "$HOME/.PlayOnLinux//wineprefix/Steam/drive_c/./Program Files/Steam"

# Lista de Videojuegos segun su IDentificador de APPlicacion en STEAM :
STEAMID=( 
"204360"    # Castle Crashers(TM)
"205230"    # Hell Yeah! Wrath of the Dead Rabbit
"205950"    # Jet Set Radio (Puede que necesites intercambiar el nombre de ambos ejecutables)
"215100"    # Ragnarok Online
"218640"    # Lucius
"22000"     # World Of Goo                  - Ya esta Portado a Liñux
"222900"    # Dead Island: Epidemic             - La Pagina de la tienda ya no existe
"224220"    # Pressure
"235720"    # Cubetractor
"253900"    # Knights and Merchants
"254000"    # East India Company Gold           - La Pagina de la tienda ya no existe
"254040"    # Pirates Of Black Cove Gold            - La Pagina de la tienda ya no existe
"254060"    # KnightShift
"254100"    # World War II: Panzer Claws
"258200"    # Talisman: Prologue
"259320"    # Heli Heroes
"267920"    # Gun Metal
"267940"    # Glacier 3: The Meltdown
"267960"    # Hyper Fighters
"267980"    # Hostile Waters: Antaeus Rising
"271640"    # Humanity Asset
"274900"    # Murder Miners
"278490"    # Aveyond 3-2: Gates of Night
"279640"    # The Troma Project
"283330"    # Desert Thunder
"283350"    # Eurofighter Typhoon
"283410"    # CT Special Forces: Fire for Effect
"284950"    # Pixel Puzzles: Japan
"285840"    # Enemy Mind
"286440"    # Rover Rescue
"292380"    # Racer 8
"292390"    # Realms Of The Hauting (DOSBox)
"292410"    # Street Racing Syndicate
"293180"    # Overcast - Walden and the Werewolf
"296910"    # 8BitBoy TM
"306350"    # Slipstream 5000
"307070"    # Memories of a Vagabond
"307350"    # Nux
"310450"    # Steam & Steel : Episode 1
"311480"    # Vertical Drop Heroes HD
"315430"    # Polarity
"319180"    # Platypus II
"321150"    # Melissa K. and the Heart of Gold Collector's Edition
"323630"    # Ubinota
"331710"    # Why So Evil
"34270"     # SEGA MegaDrive & Genesis Classics     - La Pagina de la tienda ya no existe
"343360"    # Particula
"344040"    # Voxelized
"344130"    # Cataegis : The White Wind
"347560"    # Terra Incognita ~ Chapter One: The Descendant
"350810"    # Pixel Puzzles 2: Anime
"351030"    # Pixel Puzzles Ultimate
"351470"    # Sometimes: Success Requires Sacrifice
"3590"      # Plants -VS- Zombies GOTY
"37400"     # Time Gentlemen, Please! and Ben There, Dan That! Special Edition Double Pack
"37420"     # Time Gentlemen, Please! and Ben There, Dan That! Special Edition Double Pack
"382490"    # Relic Hunters Zero
"385200"    # Absconding Zatwor
"395170"    # DISTRAINT
"395980"    # Break Into Zatwor
"410560"    # Trinium Wars
"42500"     # DogFighter
"428430"    # Endorlight
"447880"    # Beast Blaster
"4720"      # Condemned: Criminal Origins
"517320"    # GunGirl2
"57690"     # Tropico 4: Steam Special Edition
"6850"      # Hitman 2: Silent Assassin
"7510"      # X-Blades
"7520"      # Two Worls II
#"91200"    # Anomaly: Warzone Earth            - Ya esta Portado a Liñux
#"200710"   # TorchLight II                 - Ya esta Portado a Liñux
#"238910"   # Bionic Dues ( Ya portado a Liñux )
#"253920"   # Gorky 17                  - Usa su propia version de Wine
#"253940"   # Septerra Core                 - Usa su propia version de Wine
#"253980"   # Enclave                   - Usa su propia version de Wine
#"254020"   # Commander : Conquest Of the Americas Gold - La Pagina de la tienda ya no existe
#"259280"   # Earth 2150 : The Moon Project         - La Pagina de la tienda ya no existe
#"259300"   # Earth 2150 : Lost Souls           - La Pagina de la tienda ya no existe
#"259360"   # Chicken Shoot 2               - La Pagina de la tienda ya no existe
#"278460"   # SkyBorn                   - Ya esta Portado a Liñux
#"382240"   # Blood Of Old (OLD VERSION)            - La Pagina de la tienda ya no existe
#"38740"    # EDGE                      - Ya esta Portado a Liñux
#"48000"    # LIMBO (Ya esta Portado a Liñux)
)

# En caso de que el parametro posea algun numero de la lista
# Iniciar el Steam Nativo para Windows desde PlayOnLinux :

         #IDEA 1 :
         #IDEA1#STEAMWIN=$(exec wine Steam.exe -no-dwrite -no-cef-sandbox "$1" &> /dev/null)
         #IDEA1#    case $1 in
         #IDEA1#    steam://run/3590) if [ "$1" = "$@"]; then $STEAMWIN; fi ;;
         #IDEA1#    esac
         #IDEA 2 :
         #while (( ${#STEAMID[@]}+1 ))
         #do
         #
         #IDEA 3 :
         #  for i in ${!STEAMID[*]}; do
         #
         #IDEA 4 :
         # if [ "${STEAMID[*]}" = "$@" ]; then

            case $1 in
            *)
                    echo
                    echo 'Parametro de Lanzamiento -> '"$@"''
                    echo
                    exec wine Steam.exe -no-dwrite -no-cef-sandbox "$@" &> /dev/null
                    echo
                    echo
                    exit 0
                    ;;
            esac

            # En caso de usar do, finalizar con "done" :
            #done

# En caso de que el parametro no pesea ningun numero de la lista
# Iniciar el Steam Nativo para Liñux

        # Correcion para Steam para que me deje de dar errores como :
        # Could not find required OpenGL entry point :
        # 'glColorMaskIndexedEXT'
        # 'GLGetError'!
        # 'glUseProgramStages'!
        #
        export PATH="/media/Compartido/Videojuegos/Gestor/Linux/Steam/Slackware64/home/bin/":$PATH
        export GAME_DEBUGGER="hl2debug"
    hl2debug

If I understand correctly you wish to check whether some id is contained within the array STEAMID , then all you need is a simple comparison in bash using the =~ operator with [[ ... ]] . 如果我理解正确,则希望检查STEAMID数组中是否包含某些id ,那么您所需要的就是使用=~运算符和[[ ... ]]在bash中进行简单比较。 For example to check for id=321150 , you can use something like: 例如,要检查id=321150 ,可以使用类似以下内容的东西:

id=321150
[[ ${STEAMID[@]} =~ $id ]] && echo "start windows: $id" || echo "use Gnu"

If id=321150 exists in STEAMID (it does), so the echo "start windows: $id" would execute, otherwise the echo "use Gnu" would execute. 如果id=321150中存在STEAMID (它),所以echo "start windows: $id"将执行,否则echo "use Gnu"将执行。 You can adapt as required, using if ... then ... else ... fi instead of the compound statement if you like. 您可以根据需要进行调整, if ... then ... else ... fi需要,可以使用if ... then ... else ... fi代替复合语句 But that is how I would check whether the id exists in the STEAMID array for purposes of windows/linux launch of steam:// if I understood your question. 但是,如果我理解您的问题,那么这就是为了在Windows / Linux上启动steam://目的而检查STEAMID数组中是否存在id

Example Use/Output 使用/输出示例

$ id=321150; [[ ${STEAMID[@]} =~ $id ]] && echo "start windows: $id"
start windows: 321150

If you are looking for something else, and I did not correctly understand the question, drop a comment and I'm happy to help further. 如果您正在寻找其他东西,但我对问题的理解不正确,请发表评论,我们很乐意为您提供进一步的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM