Include arch-independent builds

This commit is contained in:
oitsjustjose 2024-12-11 00:36:48 -06:00
commit 97e3456250
4 changed files with 69 additions and 69 deletions

BIN
pixlet.aarch64 Normal file

Binary file not shown.

BIN
pixlet.x86_64 Normal file

Binary file not shown.

View file

@ -2,24 +2,25 @@
import subprocess import subprocess
from pathlib import Path from pathlib import Path
from platform import machine
from renderables import Renderable from renderables import Renderable
ROOT_PATH = Path("./").resolve() class PixletHelper:
PIXLET_EXEC = ROOT_PATH.joinpath("pixlet").resolve() def __init__(self):
self.root_path = Path("./").resolve()
self.pixlet = self.root_path.joinpath(f"pixlet.{machine()}").resolve()
def push_to_tidbyt(self, renderable: Renderable) -> None:
def push_to_tidbyt(renderable: Renderable) -> None:
"""Pushes a renderable to the Tidbyt device """Pushes a renderable to the Tidbyt device
Args: Args:
renderable (Renderable): The Pixlet Configuration for the given state renderable (Renderable): The Pixlet Configuration for the given state
""" """
__display(__render(renderable)) self.__display(self.__render(renderable))
def __render(self, renderable: Renderable) -> Path:
def __render(renderable: Renderable) -> Path:
"""Renders a given PixeltConfiguration (and any template args) to webp """Renders a given PixeltConfiguration (and any template args) to webp
Args: Args:
@ -28,15 +29,14 @@ def __render(renderable: Renderable) -> Path:
Returns: Returns:
Path: The path to the rendered output file Path: The path to the rendered output file
""" """
output_path = __prepare_file(renderable) output_path = self.__prepare_file(renderable)
with subprocess.Popen([PIXLET_EXEC, "render", str(output_path)]) as proc: with subprocess.Popen([self.pixlet, "render", str(output_path)]) as proc:
proc.wait() proc.wait()
return ROOT_PATH.joinpath("tmp.webp").resolve() return self.root_path.joinpath("tmp.webp").resolve()
def __display(self, path: Path) -> None:
def __display(path: Path) -> None:
"""Pushes a given rendered webp file to the pixlet on the same installation id """Pushes a given rendered webp file to the pixlet on the same installation id
Args: Args:
@ -44,13 +44,13 @@ def __display(path: Path) -> None:
""" """
with open( with open(
ROOT_PATH.joinpath("device_id").resolve(), "r", encoding="utf8" self.root_path.joinpath("device_id").resolve(), "r", encoding="utf8"
) as handle: ) as handle:
dev_id = handle.read() dev_id = handle.read()
with subprocess.Popen( with subprocess.Popen(
[ [
PIXLET_EXEC, self.pixlet,
"push", "push",
"--installation-id", "--installation-id",
"automation", "automation",
@ -60,8 +60,7 @@ def __display(path: Path) -> None:
) as proc: ) as proc:
proc.wait() proc.wait()
def __prepare_file(self, renderable: Renderable) -> Path:
def __prepare_file(renderable: Renderable) -> Path:
"""Prepares a given pixlet star file. If the file is a template, checks the template keys and prepares the template before writing to the temp path """Prepares a given pixlet star file. If the file is a template, checks the template keys and prepares the template before writing to the temp path
Args: Args:
@ -73,7 +72,7 @@ def __prepare_file(renderable: Renderable) -> Path:
Returns: Returns:
Path: The path to the output file Path: The path to the output file
""" """
output_path = ROOT_PATH.joinpath("tmp.star").resolve() output_path = self.root_path.joinpath("tmp.star").resolve()
with open(renderable.file_path, "r", encoding="utf8") as handle: with open(renderable.file_path, "r", encoding="utf8") as handle:
data = handle.read() data = handle.read()

View file

@ -4,7 +4,7 @@ from threading import Thread
from time import sleep from time import sleep
from typing import Dict from typing import Dict
from pixlet import push_to_tidbyt from pixlet import PixletHelper
from renderables import Renderable from renderables import Renderable
from renderables.forgeserv import ForgeServ from renderables.forgeserv import ForgeServ
@ -47,6 +47,7 @@ class StateManager:
self.timeout = timeout self.timeout = timeout
self.thread: Thread = None self.thread: Thread = None
self.stop_thread = False self.stop_thread = False
self.__pixlet_helper = PixletHelper()
self.__start() self.__start()
def update(self, new_state: AppState): def update(self, new_state: AppState):
@ -59,7 +60,7 @@ class StateManager:
return self.state return self.state
self.state = new_state self.state = new_state
push_to_tidbyt(self.renderables[self.state]) self.__pixlet_helper.push_to_tidbyt(self.renderables[self.state])
def __start(self): def __start(self):
"""Instantiates and starts the worker thread """Instantiates and starts the worker thread
@ -76,5 +77,5 @@ class StateManager:
"""A looping task that renders and pushes the correct pixlet based on state""" """A looping task that renders and pushes the correct pixlet based on state"""
while not self.stop_thread: while not self.stop_thread:
if self.renderables[self.state].is_dynamic: if self.renderables[self.state].is_dynamic:
push_to_tidbyt(self.renderables[self.state]) self.__pixlet_helper.push_to_tidbyt(self.renderables[self.state])
sleep(self.timeout) sleep(self.timeout)