Skip to content

Commit 2cef131

Browse files
committed
works on linux!
1 parent 78fe370 commit 2cef131

3 files changed

Lines changed: 32 additions & 86 deletions

File tree

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: build
2-
on: [workflow_dispatch]
2+
on: [push, workflow_dispatch]
33

44
jobs:
55
build-for-linux:
@@ -28,9 +28,9 @@ jobs:
2828
- name: build
2929
shell: bash
3030
run: |
31-
pyinstaller main.py --onefile --name=liquidWeb-cli -i "NONE"
32-
pyinstaller framereceiver.py --onefile --name=frame-receiver -i "NONE"
33-
pyinstaller hardwareserver.py --name=hardware-server -i "NONE"
31+
pyinstaller main.py --onefile --name=liquidWeb-cli
32+
pyinstaller framereceiver.py --onefile --name=frame-receiver
33+
pyinstaller hardwareserver.py --onefile --name=hardware-server
3434
cd integration-runner
3535
npm run package
3636
- name: package

driver.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,17 @@
3434

3535
Resolution = namedtuple("Resolution", ["width", "height"])
3636

37-
3837
class RENDERING_MODE(str, Enum):
3938
RGBA = "RGBA"
4039
GIF = "GIF"
4140
FAST_GIF = "FAST_GIF"
4241
Q565 = "Q565"
4342

44-
4543
class DISPLAY_MODE(IntEnum):
4644
LIQUID = 2
4745
BUCKET = 4
4846
FAST_BUCKET = 5
4947

50-
5148
SUPPORTED_DEVICES = [
5249
{
5350
"pid": 0x3008,
@@ -90,7 +87,6 @@ class DISPLAY_MODE(IntEnum):
9087
}
9188
]
9289

93-
9490
class KrakenLCD:
9591
pid: int
9692
serial: str
@@ -107,7 +103,6 @@ class KrakenLCD:
107103
buckets_to_use = 2
108104
black: Image.Image
109105
mask: Image.Image
110-
111106
cache = None
112107

113108
def __init__(self, brightness, orientation):
@@ -126,7 +121,7 @@ def __init__(self, brightness, orientation):
126121
dev["maxBucketSize"],
127122
(self.resolution.width * self.resolution.height * 4),
128123
)
129-
self.buckets_to_use = max(self.totalBuckets, 2)
124+
self.buckets_to_use = max(self.total_buckets, 2)
130125
self.brightness = brightness
131126
self.orientation = orientation
132127
self.speed_channels = dev["speedChannels"]
@@ -155,7 +150,8 @@ def __init__(self, brightness, orientation):
155150
if self.bulk_dev is None:
156151
raise ValueError("Device not found or serial number mismatch.")
157152
except Exception:
158-
raise Exception("Could not connect to kraken device. Is NZXT CAM closed ?")
153+
# https://github.com/liquidctl/liquidctl/blob/main/extra/linux/71-liquidctl.rules
154+
raise Exception("Could not connect to kraken device. Do you have the required permissions?")
159155

160156
self.black = Image.new("RGBA", self.resolution, (0, 0, 0, 0))
161157
self.mask = Image.new("RGBA", self.resolution, (0, 0, 0, 0))
@@ -279,8 +275,7 @@ def delete_bucket(self, bucket: int, retries=1) -> bool:
279275
def delete_all_buckets(self):
280276
for bucket in range(self.total_buckets):
281277
for i in range(10):
282-
status = self.deleteBucket(bucket, i)
283-
278+
status = self.delete_bucket(bucket, i)
284279
if status:
285280
break
286281
time.sleep(0.1)
@@ -312,7 +307,7 @@ def create_bucket(
312307
status = self.read_until({b"\x33\x01": self.parse_standard_result})
313308
return status
314309

315-
def write_RGBA(self, RGBAData: bytes, bucket: int) -> bool:
310+
def write_RGBA(self, RGBA_data: bytes, bucket: int) -> bool:
316311
self.write([0x36, 0x01, bucket])
317312
status = self.read_until({b"\x37\x01": self.parse_standard_result})
318313
if not status:
@@ -326,11 +321,11 @@ def write_RGBA(self, RGBAData: bytes, bucket: int) -> bool:
326321
0x00,
327322
0x00,
328323
]
329-
+ list(len(RGBAData).to_bytes(4, "little"))
324+
+ list(len(RGBA_data).to_bytes(4, "little"))
330325
)
331326

332327
self.bulk_write(bytes(header))
333-
self.bulk_write(RGBAData)
328+
self.bulk_write(RGBA_data)
334329

335330
self.write([0x36, 0x02, bucket])
336331
status = self.read_until({b"\x37\x02": self.parse_standard_result})
@@ -402,7 +397,6 @@ def write_frame(self, frame: bytes):
402397
self.next_frame_bucket * ((self.max_RGBA_bucket_size) / 1024 + 1)
403398
).to_bytes(2, "little")
404399
)
405-
406400
result = (
407401
(
408402
self.delete_bucket(self.next_frame_bucket)

main.py

Lines changed: 21 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
# This file is mostly Windows slop but until my Linux switch it has to stay that way
2-
3-
from PIL import Image
41
import subprocess
5-
import threading
6-
import win32gui
7-
import win32con
8-
import pystray
92
import signal
103
import time
114
import sys
@@ -17,56 +10,37 @@
1710
configuration = 0
1811
width = 0
1912
height = 0
20-
tray = 0
2113
PORT = 54217
2214

23-
argumentsCount = len(sys.argv)
15+
arguments_count = len(sys.argv)
2416
minimum = False
25-
stopRequested = False
26-
hideOnce = False
27-
program = win32gui.GetForegroundWindow()
2817

29-
def notEnoughArguments():
18+
def not_enough_arguments():
3019
print("[MAIN] Not enough arguments provided")
31-
print("[MAIN] Usage: liquidWeb configuration (0-1) url fps (0-30) brightness (0-100%) orientation (0-360°) system-tray (0-1) port (Optional. Will use the selected one plus two next ones. Default 54217,54218,54219)")
20+
print("[MAIN] Usage: liquidWeb configuration (0-1) url fps (0-30) brightness (0-100%) orientation (0-360°) port (Optional. Will use the selected one plus two next ones. Default 54217, 54218, 54219)")
3221
sys.exit()
3322

34-
def trayQuit(icon, item):
35-
global stopRequested
36-
stopRequested = True
37-
icon.stop()
38-
39-
def show(icon, item):
40-
win32gui.ShowWindow(program, win32con.SW_RESTORE)
41-
42-
def trayThread():
43-
img = Image.new("RGB", (16, 16), (80, 0, 121))
44-
icon = pystray.Icon(name="liquidWeb-cli", title="liquidWeb", icon=img, menu=pystray.Menu(
45-
pystray.MenuItem("Show", show),
46-
pystray.MenuItem("Quit", trayQuit)
47-
))
48-
icon.run()
49-
50-
if argumentsCount >= 3:
23+
if arguments_count >= 3:
5124
configuration = sys.argv[1]
5225
url = sys.argv[2]
53-
if argumentsCount == 3:
26+
if arguments_count == 3:
5427
minimum = True
5528
else:
56-
notEnoughArguments()
57-
if argumentsCount >= 6:
29+
not_enough_arguments()
30+
if arguments_count >= 6:
5831
fps = sys.argv[3]
32+
if fps > 30:
33+
print("[MAIN] Can't set more than 30 fps")
34+
fps = 30
5935
brightness = sys.argv[4]
6036
orientation = sys.argv[5]
6137
else:
6238
if not minimum:
63-
notEnoughArguments()
64-
if argumentsCount >= 7:
65-
tray = sys.argv[6]
66-
if argumentsCount >= 8:
67-
PORT = sys.argv[7]
39+
not_enough_arguments()
40+
if arguments_count >= 7:
41+
PORT = sys.argv[6]
6842

69-
if argumentsCount == 3:
43+
if arguments_count == 3:
7044
width = 1280
7145
height = 720
7246
fps = 60
@@ -75,41 +49,19 @@ def trayThread():
7549
height = 640
7650
configuration = 0
7751

78-
subprocess.call("net stop hns")
79-
subprocess.call("net start hns")
52+
#subprocess.call("taskkill /im integration-runner.exe /f /t")
53+
#subprocess.call("taskkill /im frame-receiver.exe /f /t")
54+
#subprocess.call("taskkill /im hardware-server.exe /f /t")
8055

81-
subprocess.call("taskkill /im integration-runner.exe /f /t")
82-
subprocess.call("taskkill /im frame-receiver.exe /f /t")
83-
subprocess.call("taskkill /im hardware-server.exe /f /t")
84-
85-
time.sleep(5)
86-
87-
p1 = subprocess.Popen(["./modules/integration-runner-win32-x64/integration-runner.exe", f"--width={width}", f"--height={height}", f"--fps={fps}", f"--configuration={configuration}", f"--url={url}", f"--port={PORT}"])
88-
if argumentsCount >= 5:
56+
p1 = subprocess.Popen(["./modules/integration-runner-linux-x64/integration-runner", f"--width={width}", f"--height={height}", f"--fps={fps}", f"--configuration={configuration}", f"--url={url}", f"--port={PORT}"])
57+
if arguments_count >= 5:
8958
p2 = subprocess.Popen(["./modules/frame-receiver", f"{brightness}", f"{orientation}", f"{PORT}"])
9059
p3 = subprocess.Popen(["./modules/hardware-server/hardware-server", f"{int(PORT) + 1}"])
9160

92-
if tray == "1":
93-
threading.Thread(target=trayThread, daemon=True).start()
94-
9561
try:
9662
while True:
9763
time.sleep(1)
98-
if tray == "1" and not hideOnce:
99-
win32gui.ShowWindow(program , win32con.SW_HIDE)
100-
hideOnce = True
101-
if tray == "1" and hideOnce:
102-
placement = win32gui.GetWindowPlacement(program)
103-
if placement[1] == win32con.SW_SHOWMINIMIZED:
104-
win32gui.ShowWindow(program , win32con.SW_HIDE)
105-
if stopRequested:
106-
win32gui.ShowWindow(program, win32con.SW_RESTORE)
107-
p1.terminate()
108-
p2.send_signal(signal.CTRL_BREAK_EVENT)
109-
p3.terminate()
110-
print("[MAIN] Requested quit from tray icon")
111-
break
112-
if argumentsCount >= 6:
64+
if arguments_count >= 6:
11365
if p1.poll() is not None or p2.poll() is not None or p3.poll() is not None:
11466
print("[MAIN] One process exited, shutting down the other")
11567
break
@@ -121,6 +73,6 @@ def trayThread():
12173
print(f"[MAIN] {e}")
12274
print("[MAIN] Stopping")
12375
p1.terminate()
124-
if argumentsCount >= 6:
76+
if arguments_count >= 6:
12577
p2.send_signal(signal.CTRL_BREAK_EVENT)
12678
p3.terminate()

0 commit comments

Comments
 (0)