generated from SteamDeckHomebrew/decky-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 40
/
main.py
45 lines (38 loc) · 1.34 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
import logging
import subprocess
import asyncio
import os
from config import logger, setup_logger
import update
import decky_plugin
import utils
class Plugin:
backend_proc = None
# Asyncio-compatible long-running code, executed in a task when the plugin is loaded
async def _main(self):
logger = setup_logger()
utils.write_font_config()
logger.info("Start Tomoon.")
os.system('chmod -R a+x ' + decky_plugin.DECKY_PLUGIN_DIR)
# 切换到工作目录
os.chdir(decky_plugin.DECKY_PLUGIN_DIR)
self.backend_proc = subprocess.Popen([decky_plugin.DECKY_PLUGIN_DIR + "/bin/tomoon"])
while True:
await asyncio.sleep(1)
# Function called first during the unload process, utilize this to handle your plugin being removed
async def _unload(self):
logger.info("Stop Tomoon.")
self.backend_proc.kill()
utils.remove_font_config()
pass
async def update_latest(self):
logger.info("Updating latest")
return update.update_latest()
async def get_version(self):
version = update.get_version()
logger.info(f"Current version: {version}")
return version
async def get_latest_version(self):
version = update.get_latest_version()
logger.info(f"Latest version: {version}")
return version