Author Topic: [Linux] Different Behavior When Launched from Terminal vs. Desktop  (Read 1419 times)

Sea Monkey

  • Jr. Member
  • **
  • Posts: 12
    • View Profile
[Linux] Different Behavior When Launched from Terminal vs. Desktop
« on: September 13, 2020, 01:41:49 PM »
I use a script for launching PCSX2 with per-game configs and memory cards.  It works fine if attract is launched from the terminal, but when launched from the desktop, PCSX2 doesn't appear to launch at all. In order to use the script when launching Attract Mode from the desktop, in the .desktop file, I must change `Terminal=false` to true.  Can anyone explain why this is?  Here is the script in question:

Code: [Select]
#!/bin/bash
## This script makes it possible to user individual per game configuration files for PCSX2.
## Make sure your default PCSX2_ui.ini has Slot1_Filename set to default.ps2.
## This script only seems to work correctly with Attract Mode when attract is launched via terminal.
## Tested with PCSX2 1.5.0 through 1.7.0.
## Credit to parasven for the RetroPie script that was the basis for this.

pcsx2_ini="$HOME/.config/PCSX2/PCSX2-reg.ini"
game_configpath="$HOME/.config/PCSX2/game_configs"
memcardpath="$HOME/.config/PCSX2/memcards"
pcsx2_config_default="$HOME/.config/PCSX2/inis"
fullfilename=$1
filename=$(basename "$fullfilename")
title_id="${filename%.*}"
memcard="$title_id.ps2"

## If no parameter was passed, set default path and exit.
if [[ ! $1 ]]
then
        ## Exchange the configpath
        sed -i s@"^SettingsFolder=.*"@"SettingsFolder=\"$pcsx2_config_default\""@g "$pcsx2_ini"
        exit
fi

## When the config folder does not exist, create it and copy over the default inis from the default ini folder.
if [[ ! -e "$game_configpath/$title_id"  ]]
then
        ## Create folder based on the filename of the game.
        mkdir -p "$game_configpath/$title_id/"
        ## Copy over the default inis from default directory for a start.
        cp -a "$pcsx2_config_default"/*.ini "$game_configpath/$title_id/"
fi

## If game-specific memory card does not exist, then create it using blank default.
if [[ ! -e "$memcardpath/$memcard"  ]]
then
## Copy default memcard
cp "$memcardpath"/default.ps2 "$memcardpath/$memcard"
fi

echo "memcard = $memcard"

# Load relevant memory card.
sed -i "s|default.ps2|$memcard|g" "$game_configpath/$title_id/"PCSX2_ui.ini

# Launch PCSX2 using the relevant config folder.
/usr/games/PCSX2 --fullscreen --fullboot --cfgpath="$game_configpath/$title_id" "$1" &

# Close PCSX2 when Attract Mode's 'Exit Emulator' hotkey is pressed. 
cleanup() {
        echo "Caugh Signal ... terminating PCSX2."
        pkill PCSX2
        exit
}
trap cleanup INT TERM
read var
cleanup
« Last Edit: September 13, 2020, 01:53:11 PM by Sea Monkey »

akafox

  • Hero Member
  • *****
  • Posts: 985
    • View Profile
Re: [Linux] Different Behavior When Launched from Terminal vs. Desktop
« Reply #1 on: September 18, 2020, 06:28:33 PM »
I am replying here to let you know I have heard you. I will do some testing of my own and see if I can help you out and get back to you tomorrow.

so you use this script? Can I ask why? (Just need more info...)

also could you post your AM config file for that emulator please? :)
People want life easy..then complain about it