Convert executables to strings at init time
This commit is contained in:
@@ -35,9 +35,9 @@ Stored as a Unix time stamp.
|
|||||||
|
|
||||||
The executable to run when launching a game.
|
The executable to run when launching a game.
|
||||||
|
|
||||||
If the source has a URL handler, using that is preferred. In that case, the value should be `["xdg-open", "url://example/url"]` for Linux and `["start", "url://example/url"]` for Windows.
|
If the source has a URL handler, using that is preferred. In that case, the value should be `"xdg-open url://example/url"` for Linux and `"start url://example/url"` for Windows.
|
||||||
|
|
||||||
Stored as either a string or an argument vector to be passed to the shell through [subprocess.Popen](https://docs.python.org/3/library/subprocess.html#popen-constructor).
|
Stored as either a string (preferred) or an argument vector to be passed to the shell through [subprocess.Popen](https://docs.python.org/3/library/subprocess.html#popen-constructor).
|
||||||
|
|
||||||
### game_id
|
### game_id
|
||||||
|
|
||||||
|
|||||||
@@ -69,11 +69,7 @@ class DetailsWindow(Adw.Window):
|
|||||||
self.name.set_text(self.game.name)
|
self.name.set_text(self.game.name)
|
||||||
if self.game.developer:
|
if self.game.developer:
|
||||||
self.developer.set_text(self.game.developer)
|
self.developer.set_text(self.game.developer)
|
||||||
self.executable.set_text(
|
self.executable.set_text(self.game.executable)
|
||||||
self.game.executable
|
|
||||||
if isinstance(self.game.executable, str)
|
|
||||||
else shlex.join(self.game.executable)
|
|
||||||
)
|
|
||||||
self.apply_button.set_label(_("Apply"))
|
self.apply_button.set_label(_("Apply"))
|
||||||
|
|
||||||
self.game_cover.new_cover(self.game.get_cover_path())
|
self.game_cover.new_cover(self.game.get_cover_path())
|
||||||
|
|||||||
13
src/game.py
13
src/game.py
@@ -86,6 +86,9 @@ class Game(Gtk.Box):
|
|||||||
|
|
||||||
def update_values(self, data):
|
def update_values(self, data):
|
||||||
for key, value in data.items():
|
for key, value in data.items():
|
||||||
|
# Convert executables to strings
|
||||||
|
if key == "executable" and isinstance(value, list):
|
||||||
|
value = shlex.join(value)
|
||||||
setattr(self, key, value)
|
setattr(self, key, value)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
@@ -115,16 +118,10 @@ class Game(Gtk.Box):
|
|||||||
self.save()
|
self.save()
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
string = (
|
|
||||||
self.executable
|
|
||||||
if isinstance(self.executable, str)
|
|
||||||
else shlex.join(self.executable)
|
|
||||||
)
|
|
||||||
|
|
||||||
args = (
|
args = (
|
||||||
"flatpak-spawn --host /bin/sh -c " + shlex.quote(string) # Flatpak
|
"flatpak-spawn --host /bin/sh -c " + shlex.quote(self.executable) # Flatpak
|
||||||
if os.getenv("FLATPAK_ID") == shared.APP_ID
|
if os.getenv("FLATPAK_ID") == shared.APP_ID
|
||||||
else string # Others
|
else self.executable # Others
|
||||||
)
|
)
|
||||||
|
|
||||||
logging.info("Starting %s: %s", self.name, str(args))
|
logging.info("Starting %s: %s", self.name, str(args))
|
||||||
|
|||||||
Reference in New Issue
Block a user