Set last_played if launching from the command line
This commit is contained in:
@@ -22,6 +22,7 @@ import lzma
|
|||||||
import os
|
import os
|
||||||
import shlex
|
import shlex
|
||||||
import sys
|
import sys
|
||||||
|
from time import time
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
import gi
|
import gi
|
||||||
@@ -170,7 +171,9 @@ class CartridgesApplication(Adw.Application):
|
|||||||
if arg == "--launch":
|
if arg == "--launch":
|
||||||
try:
|
try:
|
||||||
game_id = args[index + 1]
|
game_id = args[index + 1]
|
||||||
data = json.load((shared.games_dir / (game_id + ".json")).open("r"))
|
data = json.load(
|
||||||
|
(path := shared.games_dir / (game_id + ".json")).open("r")
|
||||||
|
)
|
||||||
executable = (
|
executable = (
|
||||||
shlex.join(data["executable"])
|
shlex.join(data["executable"])
|
||||||
if isinstance(data["executable"], list)
|
if isinstance(data["executable"], list)
|
||||||
@@ -179,6 +182,10 @@ class CartridgesApplication(Adw.Application):
|
|||||||
name = data["name"]
|
name = data["name"]
|
||||||
|
|
||||||
run_executable(executable)
|
run_executable(executable)
|
||||||
|
|
||||||
|
data["last_played"] = int(time())
|
||||||
|
json.dump(data, path.open("w"))
|
||||||
|
|
||||||
except (IndexError, KeyError, OSError, json.decoder.JSONDecodeError):
|
except (IndexError, KeyError, OSError, json.decoder.JSONDecodeError):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user