forked from SteamDeckHomebrew/decky-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
45 lines (34 loc) · 1.49 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 os
# The decky plugin module is located at decky-loader/plugin
# For easy intellisense checkout the decky-loader code one directory up
# or add the `decky-loader/plugin` path to `python.analysis.extraPaths` in `.vscode/settings.json`
import decky
import plugin_config
import logger_utils
class Plugin:
# A normal method. It can be called from JavaScript using call_plugin_function("method_1", argument1, argument2)
async def add(self, left, right):
return left + right
# Configuration
async def get_config(self):
decky.logger.debug("Executing: get_config()")
return plugin_config.get_config()
async def set_config(self, key: str, value):
decky.logger.debug("Executing: set_config(%s, %s)", key, str(value))
plugin_config.set_config(key, value)
# Logger
async def log(self, level: str, msg: str) -> int:
decky.logger.debug("Executing: log()")
return logger_utils.log(level, msg)
async def get_plugin_log(self) -> str:
decky.logger.debug("Executing: get_plugin_log()")
return logger_utils.get_plugin_log()
# Lifecycle
async def _main(self):
logger_utils.configure_logger()
decky.logger.info("Running "+decky.DECKY_PLUGIN_NAME)
async def _unload(self):
decky.logger.info("Unloading "+decky.DECKY_PLUGIN_NAME)
async def _migration(self):
decky.logger.info("Migrating plugin configuration")
plugin_config.migrate()