-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.py
273 lines (246 loc) · 9.67 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
from src.backend.PluginManager.ActionBase import ActionBase
from src.backend.PluginManager.PluginBase import PluginBase
from src.backend.PluginManager.ActionHolder import ActionHolder
from src.backend.DeckManagement.InputIdentifier import Input
from src.backend.PluginManager.ActionInputSupport import ActionInputSupport
# Import gtk modules
import gi
gi.require_version("Gtk", "4.0")
gi.require_version("Adw", "1")
from gi.repository import Gtk, Adw
import sys
import os
import webbrowser
from loguru import logger as log
from PIL import Image, ImageEnhance
import math
import threading
import subprocess
import time
from evdev import ecodes
from evdev import UInput
from src.backend.DeckManagement.DeckController import DeckController
from src.backend.PageManagement.Page import Page
from .Hotkey import Hotkey
from .EasyHotkey import EasyHotkey
from .Launch import Launch
from .actions.RunCommand.RunCommand import RunCommand
from .actions.EasyCommand.EasyCommand import EasyCommand
from .actions.OpenInBrowser.OpenInBrowser import OpenInBrowser
from .actions.Delay.Delay import Delay
from .CPU_Graph import CPU_Graph
from .RAM_Graph import RAM_Graph
from .MoveXY import MoveXY
from .Click import Click
from .actions.CPU.CPU import CPU
from .actions.CPU.CPUTemp import CPUTemp
from .actions.RAM.RAM import RAM
from .actions.WriteText.WriteText import WriteText
# Add plugin to sys.paths
sys.path.append(os.path.dirname(__file__))
class OSPlugin(PluginBase):
def __init__(self):
self.PLUGIN_NAME = "OS"
self.GITHUB_REPO = "https://github.com/your-github-repo"
super().__init__()
self.ui = None
self.init_vars()
self.run_command_holder = ActionHolder(
plugin_base=self,
action_base=RunCommand,
action_id_suffix="RunCommand",
action_name=self.lm.get("actions.run-command.name"),
action_support={
Input.Key: ActionInputSupport.SUPPORTED,
Input.Dial: ActionInputSupport.SUPPORTED,
Input.Touchscreen: ActionInputSupport.UNTESTED
}
)
self.add_action_holder(self.run_command_holder)
self.easy_command_holder = ActionHolder(
plugin_base=self,
action_base=EasyCommand,
action_id_suffix="EasyCommand",
action_name="Easy Run Command",
action_support={
Input.Key: ActionInputSupport.SUPPORTED,
Input.Dial: ActionInputSupport.UNTESTED,
Input.Touchscreen: ActionInputSupport.UNTESTED
}
)
self.add_action_holder(self.easy_command_holder)
self.open_in_browser_holder = ActionHolder(
plugin_base=self,
action_base=OpenInBrowser,
action_id_suffix="OpenInBrowser",
action_name=self.lm.get("actions.open-in-browser.name"),
action_support={
Input.Key: ActionInputSupport.SUPPORTED,
Input.Dial: ActionInputSupport.SUPPORTED,
Input.Touchscreen: ActionInputSupport.UNTESTED
}
)
self.add_action_holder(self.open_in_browser_holder)
self.hotkey_holder = ActionHolder(
plugin_base=self,
action_base=Hotkey,
action_id_suffix="Hotkey",
action_name=self.lm.get("actions.hotkey.name"),
action_support={
Input.Key: ActionInputSupport.SUPPORTED,
Input.Dial: ActionInputSupport.SUPPORTED,
Input.Touchscreen: ActionInputSupport.UNTESTED
}
)
self.add_action_holder(self.hotkey_holder)
self.easy_hotkey_holder = ActionHolder(
plugin_base=self,
action_base=EasyHotkey,
action_id_suffix="EasyHotkey",
action_name="Easy Hotkey",
action_support={
Input.Key: ActionInputSupport.SUPPORTED,
Input.Dial: ActionInputSupport.UNTESTED,
Input.Touchscreen: ActionInputSupport.UNTESTED
}
)
self.add_action_holder(self.easy_hotkey_holder)
self.delay_holder = ActionHolder(
plugin_base=self,
action_base=Delay,
action_id_suffix="Delay",
action_name=self.lm.get("actions.delay.name"),
action_support={
Input.Key: ActionInputSupport.SUPPORTED,
Input.Dial: ActionInputSupport.SUPPORTED,
Input.Touchscreen: ActionInputSupport.SUPPORTED
}
)
self.add_action_holder(self.delay_holder)
self.launch_holder = ActionHolder(
plugin_base=self,
action_base=Launch,
action_id_suffix="Launch",
action_name=self.lm.get("actions.launch.name"),
action_support={
Input.Key: ActionInputSupport.SUPPORTED,
Input.Dial: ActionInputSupport.SUPPORTED,
Input.Touchscreen: ActionInputSupport.UNTESTED
}
)
# Deactived because of problems in flatpak and app gathering
# self.add_action_holder(self.launch_holder)
self.cpu_graph_holder = ActionHolder(
plugin_base=self,
action_base=CPU_Graph,
action_id_suffix="CPU_Graph",
action_name=self.lm.get("actions.cpu-graph.name"),
action_support={
Input.Key: ActionInputSupport.SUPPORTED,
Input.Dial: ActionInputSupport.SUPPORTED,
Input.Touchscreen: ActionInputSupport.UNSUPPORTED
}
)
self.add_action_holder(self.cpu_graph_holder) #FIXME: too unstable
self.ram_graph_holder = ActionHolder(
plugin_base=self,
action_base=RAM_Graph,
action_id_suffix="RAM_Graph",
action_name=self.lm.get("actions.ram-graph.name"),
action_support={
Input.Key: ActionInputSupport.SUPPORTED,
Input.Dial: ActionInputSupport.SUPPORTED,
Input.Touchscreen: ActionInputSupport.UNSUPPORTED
}
)
self.add_action_holder(self.ram_graph_holder) #FIXME: too unstable
self.move_xy_holder = ActionHolder(
plugin_base=self,
action_base=MoveXY,
action_id_suffix="MoveXY",
action_name=self.lm.get("actions.move-xy.name"),
action_support={
Input.Key: ActionInputSupport.SUPPORTED,
Input.Dial: ActionInputSupport.SUPPORTED,
Input.Touchscreen: ActionInputSupport.UNTESTED
}
)
self.add_action_holder(self.move_xy_holder)
self.click_holder = ActionHolder(
plugin_base=self,
action_base=Click,
action_id_suffix="Click",
action_name=self.lm.get("actions.click.name"),
action_support={
Input.Key: ActionInputSupport.SUPPORTED,
Input.Dial: ActionInputSupport.SUPPORTED,
Input.Touchscreen: ActionInputSupport.UNTESTED
}
)
self.add_action_holder(self.click_holder)
self.cpu_holder = ActionHolder(
plugin_base=self,
action_base=CPU,
action_id_suffix="CPU",
action_name=self.lm.get("actions.cpu.name"),
action_support={
Input.Key: ActionInputSupport.SUPPORTED,
Input.Dial: ActionInputSupport.SUPPORTED,
Input.Touchscreen: ActionInputSupport.UNSUPPORTED
}
)
self.add_action_holder(self.cpu_holder)
self.ram_holder = ActionHolder(
plugin_base=self,
action_base=RAM,
action_id_suffix="RAM",
action_name=self.lm.get("actions.ram.name"),
action_support={
Input.Key: ActionInputSupport.SUPPORTED,
Input.Dial: ActionInputSupport.SUPPORTED,
Input.Touchscreen: ActionInputSupport.UNSUPPORTED
}
)
self.add_action_holder(self.ram_holder)
self.write_text_holder = ActionHolder(
plugin_base=self,
action_base=WriteText,
action_id_suffix="WriteText",
action_name=self.lm.get("actions.write-text.name"),
action_support={
Input.Key: ActionInputSupport.SUPPORTED,
Input.Dial: ActionInputSupport.SUPPORTED,
Input.Touchscreen: ActionInputSupport.UNTESTED
}
)
self.add_action_holder(self.write_text_holder)
self.cpu_temp_holder = ActionHolder(
plugin_base=self,
action_base=CPUTemp,
action_id_suffix="CPUTemp",
action_name="CPU Temperature",
action_support={
Input.Key: ActionInputSupport.SUPPORTED,
Input.Dial: ActionInputSupport.SUPPORTED,
Input.Touchscreen: ActionInputSupport.UNSUPPORTED
}
)
self.add_action_holder(self.cpu_temp_holder)
# Register plugin
self.register(
plugin_name=self.lm.get("plugin.name"),
github_repo="https://github.com/StreamController/OSPlugin",
plugin_version="1.0.0",
app_version="1.0.0-alpha"
)
self.add_css_stylesheet(os.path.join(self.PATH, "style.css"))
def init_vars(self):
self.lm = self.locale_manager
self.lm.set_to_os_default()
self.lm.set_fallback_language("en_US")
self.ui = None
try:
self.ui = UInput({ecodes.EV_KEY: range(0, 300),
ecodes.EV_REL: [ecodes.REL_X, ecodes.REL_Y]}, name="stream-controller-os-plugin")
except Exception as e:
log.error(e)