Compare commits
2 Commits
8f0cb6cd3f
...
e33af718dc
| Author | SHA1 | Date | |
|---|---|---|---|
| e33af718dc | |||
| 6579dac3a4 |
@ -1,21 +1,37 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
tmp = os.popen("lutris -ojl").read()
|
try:
|
||||||
games = json.loads(tmp)
|
# Получаем список игр
|
||||||
|
result = subprocess.run(["lutris", "-ojl"], capture_output=True, text=True)
|
||||||
gameslist = ""
|
games = json.loads(result.stdout)
|
||||||
concat = ""
|
|
||||||
for item in games:
|
# Формируем список названий
|
||||||
gameslist = gameslist + concat + item["name"]
|
game_names = [game["name"] for game in games]
|
||||||
concat = "\n"
|
games_list = "\n".join(game_names)
|
||||||
|
|
||||||
tmp = subprocess.getoutput("echo \"" + gameslist + "\" | wofi -n -d -p \"Select Game:\"")
|
# Выбор игры через wofi
|
||||||
|
wofi_process = subprocess.Popen(
|
||||||
for item in games:
|
["wofi", "-n", "-d", "-p", "Select Game:"],
|
||||||
if item["name"] == tmp:
|
stdin=subprocess.PIPE,
|
||||||
subprocess.Popen(["lutris","lutris:rungameid/" + str(item["id"])])
|
stdout=subprocess.PIPE,
|
||||||
break
|
text=True
|
||||||
|
)
|
||||||
|
selected_game, _ = wofi_process.communicate(input=games_list)
|
||||||
|
selected_game = selected_game.strip()
|
||||||
|
|
||||||
|
if not selected_game:
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
# Запускаем выбранную игру
|
||||||
|
for game in games:
|
||||||
|
if game["name"] == selected_game:
|
||||||
|
subprocess.Popen(["lutris", f"lutris:rungameid/{game['id']}"])
|
||||||
|
break
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error: {e}", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user