Switch to shell script to launch

This commit is contained in:
Florian Piesche committed 2024-08-30 18:03:00 +01:00
1 parent 6344cc8914
commit 2d51c0a60a
3 files changed
+29 -40

No files matched your search

-37
View File
@@ -1,37 +0,0 @@
#!/usr/bin/python
import argparse
import subprocess
xdg_data_home = os.environ["XDG_XATA_HOME"]
# Create data/saves/mods directories if needed
for directory in ["data", "saves", "mods"]:
abs_dir = os.path.join(xdg_data_home, directory)
if not os.path.isdir(abs_dir):
os.makedirs(abs_dir)
parser = argparse.ArgumentParser()
# TODO: Implement ability to select game ROM and choose correct executable based on that choice
# - check for .z64 files in data path
# - if none found, exit with error message
# - if only one found:
# - check filename or md5sum and run appropriate executable
# - if no matches, exit with error message
# - for each rom:
# - if rom filename matches selected version, run game
# - else:
# - md5sum the roms one by one
# - if one matches the selected version: use that one
# - else error out
# TODO: implement mod loading
# - if romdir parameter is relative, prefix with $XDG_DATA_HOME/mods
# - else use as is
# TODO: implement arbitrary other parameters
# - get unmatched arguments from ArgumentParser
# - pass them through to executable
default_args = ["--basedir", f"{xdg_data_home}/data", "--savedir", f"{xdg_data_home}/saves"]
subprocess.run(["pd"] + default_args)
+26
View File
@@ -0,0 +1,26 @@
#!/bin/sh
# Create user data directories if necessary
userdirs=( roms saves mods )
for path in "${userdirs[@]}"; do
if [[ ! -d "${XDG_DATA_HOME}/${path}" ]]; then
mkdir -p "${XDG_DATA_HOME}/${path}"
fi
done
# If first parameter is one of the pd executables, execute that
# and pass the remaining parameters to it; otherwise default to
# pd and pass all arguments to it
case $1 in
"pd."*)
executable=$1
params="${@:2}"
;;
*)
executable=pd
params="$@"
;;
esac
# Run game
$executable --basedir ${XDG_DATA_HOME}/roms --savedir ${XDG_DATA_HOME}/saves $params
+3 -3
View File
@@ -2,7 +2,7 @@ app-id: io.github.fgsfdsfgs.perfect_dark
runtime: org.freedesktop.Platform runtime: org.freedesktop.Platform
runtime-version: &runtime-version '23.08' runtime-version: &runtime-version '23.08'
sdk: org.freedesktop.Sdk sdk: org.freedesktop.Sdk
command: io.github.fgsfdsfgs.perfect_dark.py command: io.github.fgsfdsfgs.perfect_dark.sh
finish-args: finish-args:
# multiarch is required for 32bit binaries # multiarch is required for 32bit binaries
@@ -71,7 +71,7 @@ modules:
- type: file - type: file
path: bin/pd.pal path: bin/pd.pal
- type: file - type: file
path: io.github.fgsfdsfgs.perfect_dark.py path: io.github.fgsfdsfgs.perfect_dark.sh
- type: file - type: file
path: io.github.fgsfdsfgs.perfect_dark.png path: io.github.fgsfdsfgs.perfect_dark.png
- type: file - type: file
@@ -87,7 +87,7 @@ modules:
- mkdir -p /app/lib/i386-linux-gnu/dri/intel-vaapi-driver - mkdir -p /app/lib/i386-linux-gnu/dri/intel-vaapi-driver
# port # port
- install -Dm 755 -t /app/bin/ pd* - install -Dm 755 -t /app/bin/ pd*
- install -Dm 644 ${FLATPAK_ID}.py /app/bin/${FLATPAK_ID}.py - install -Dm 755 ${FLATPAK_ID}.sh /app/bin/${FLATPAK_ID}.sh
- install -Dm 644 ${FLATPAK_ID}.desktop /app/share/applications/${FLATPAK_ID}.desktop - install -Dm 644 ${FLATPAK_ID}.desktop /app/share/applications/${FLATPAK_ID}.desktop
- install -Dm 644 ${FLATPAK_ID}.metainfo.xml /app/share/metainfo/${FLATPAK_ID}.metainfo.xml - install -Dm 644 ${FLATPAK_ID}.metainfo.xml /app/share/metainfo/${FLATPAK_ID}.metainfo.xml
- install -Dm 644 ${FLATPAK_ID}.png /app/share/icons/hicolor/256x256/apps/${FLATPAK_ID}.png - install -Dm 644 ${FLATPAK_ID}.png /app/share/icons/hicolor/256x256/apps/${FLATPAK_ID}.png