Advertisement
Guest User

runcommand-onstart.sh

a guest
Feb 9th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. # START of the trick for custom arcade launching images #######################
  2. function custom_arcade_launching_images() {
  3. if [[ "$1" != "arcade" ]]; then
  4. return
  5. fi
  6. local emulator="$2"
  7. local rom_name="$(basename "$3")"
  8. local rom_no_ext="${rom_name%.*}"
  9. local arcade_imgs_dir="$HOME/RetroPie/roms/arcade/images"
  10. local img_no_ext="$arcade_imgs_dir/${rom_no_ext}-launching"
  11. local img
  12. local config_dir="/opt/retropie/configs"
  13. local system
  14. local system_img_no_ext
  15. local system_img
  16. local ext
  17.  
  18. # checking if it's mame or fba emulator
  19. if grep -q "^$emulator \?=" "$config_dir/mame-libretro/emulators.cfg"; then
  20. system="mame-libretro"
  21. elif grep -q "^$emulator \?=" "$config_dir/fba/emulators.cfg"; then
  22. system="fba"
  23. elif grep -q "^$emulator \?=" "$config_dir/mame-advmame/emulators.cfg"; then
  24. system="mame-advmame"
  25. elif grep -q "^$emulator \?=" "$config_dir/mame-mame4all/emulators.cfg"; then
  26. system="mame-mame4all"
  27. else
  28. return 1 # system not found
  29. fi
  30.  
  31. # checking if there's a launching image for the respective system
  32. system_img_no_ext="$config_dir/$system/launching"
  33. for ext in jpg png; do
  34. if [[ -f "$system_img_no_ext.$ext" ]]; then
  35. system_img="$system_img_no_ext.$ext"
  36. break
  37. fi
  38. done
  39. if [[ -z "$system_img" ]]; then
  40. return
  41. fi
  42.  
  43. # checking if the game already has a dedicated launching-image.
  44. for ext in jpg png; do
  45. if [[ -f "$img_no_ext.$ext" ]]; then
  46. img="$img_no_ext.$ext"
  47. break
  48. fi
  49. done
  50. # if the image is not a symlink, then do not change it
  51. if [[ -f "$img" && ! -L "$img" ]]; then
  52. return
  53. fi
  54.  
  55. # if the file doesn't exists OR is a symbolic link, then we can mess with it
  56. rm -f "$img"
  57.  
  58. # avoiding duplicated launching images with different extensions
  59. ext="${system_img##*.}"
  60. case "$ext" in
  61. jpg) rm -f "$img_no_ext.png" ;;
  62. png) rm -f "$img_no_ext.jpg" ;;
  63. esac
  64.  
  65. # Phew! We're finally ready to create the symbolic link!
  66. ln -s "$system_img" "$img_no_ext.$ext"
  67. }
  68.  
  69. custom_arcade_launching_images "$@"
  70. # END of the trick for custom arcade launching images #########################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement