-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create system_specific_arcade_launching_images.sh
- Loading branch information
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
function custom_arcade_launching_images() { | ||
if [[ "$1" != "arcade" ]]; then | ||
return | ||
fi | ||
local emulator="$2" | ||
local rom_name="$(basename "$3")" | ||
local rom_no_ext="${rom_name%.*}" | ||
local arcade_imgs_dir="$HOME/RetroPie/roms/arcade/images" | ||
local img_no_ext="$arcade_imgs_dir/$rom_no_ext" | ||
local img | ||
local config_dir="/opt/retropie/configs" | ||
local system | ||
local system_img_no_ext | ||
local system_img | ||
local ext | ||
|
||
# checking if it's mame or fba emulator | ||
if grep -q "^$emulator \?=" "$config_dir/mame/emulators.cfg"; then | ||
system="mame" | ||
elif grep -q "^$emulator \?=" "$config_dir/fba/emulators.cfg"; then | ||
system="fba" | ||
else | ||
return 1 # system not found | ||
fi | ||
|
||
# checking if there's a launching image for the respective system | ||
system_img_no_ext="$config_dir/$system/launching" | ||
for ext in jpg png; do | ||
if [[ -f "$system_img_no_ext.$ext" ]]; then | ||
system_img="$system_img_no_ext.$ext" | ||
break | ||
fi | ||
done | ||
if [[ -z "$system_img" ]]; then | ||
return | ||
fi | ||
|
||
# checking if the game already has a dedicated launching-image. | ||
for ext in jpg png; do | ||
if [[ -f "$img_no_ext.$ext" ]]; then | ||
img="$img_no_ext.$ext" | ||
break | ||
fi | ||
done | ||
# if the image is not a symlink, then do not change it | ||
if [[ -f "$img" && ! -L "$img" ]]; then | ||
return | ||
fi | ||
|
||
# if the file doesn't exists OR is a symbolic link, then we can mess with it | ||
rm -f "$img" | ||
|
||
# avoiding duplicated launching images with different extensions | ||
ext="${system_img##*.}" | ||
case "$ext" in | ||
jpg) rm -f "$img_no_ext.png" ;; | ||
png) rm -f "$img_no_ext.jpg" ;; | ||
esac | ||
|
||
# Phew! We're finally ready to create the symbolic link! | ||
ln -s "$system_img" "$img_no_ext.$ext" | ||
} | ||
|
||
custom_arcade_launching_images "$@" |