generated from SteamDeckHomebrew/decky-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.py
68 lines (50 loc) · 1.74 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import json
import os
from tokenize import String
Initialized = False
def log(text: str):
# return
try:
f = open("/tmp/log.txt", "a")
f.write(text + "\n")
f.close()
except:
pass
class Plugin:
async def startRemotePlaySession(self, player1ID, player2ID, player3ID):
commandIsValid = False
player1ID = str(player1ID)
player2ID = str(player2ID)
player3ID = str(player3ID)
log(f"IDs:\nP1:{player1ID}\nP2:{player2ID}\nP3:{player3ID}")
# Ensure Each ID is Unique
tmpDict = {}
tmpDict[player1ID] = ""
tmpDict[player2ID] = ""
tmpDict[player3ID] = ""
rc = 0
command = "export DISPLAY=:1 "
rpwCommandTemplate = os.path.dirname(__file__) + "/bin/RemotePlayWhatever.AppImage -a 291550 -i \"<playerIDString>\""
tmpList = []
for key in tmpDict.keys():
if int(key) > 0:
commandIsValid = True
tmpList.append(key)
command = command + " && " + \
rpwCommandTemplate.replace("<playerIDString>", ",".join(tmpList))
log(f"Running RPW Command: {command}")
if commandIsValid:
rc = os.system(command)
log("rpw ended with rc: " + str(rc))
# Asyncio-compatible long-running code, executed in a task when the plugin is loaded
async def _main(self):
global Initialized
if not Initialized:
Initialized = True
log("Setting permissions")
rc = 0
rc = os.system(f"chmod 777 {os.path.dirname(__file__)}/bin/RemotePlayWhatever.AppImage")
log("ended with rc: " + str(rc))
else:
log("Skipping permissions")
return