This commit is contained in:
Denis Lehmann 2025-02-01 15:44:29 +01:00
parent a77ab633ca
commit 4b372f12c8
5 changed files with 36 additions and 73 deletions

26
flake.lock generated
View file

@ -1,28 +1,11 @@
{ {
"nodes": { "nodes": {
"flake-utils": {
"locked": {
"lastModified": 1638122382,
"narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "74f7e4319258e287b0f9cb95426c9853b282730b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1642069818, "lastModified": 0,
"narHash": "sha256-666w6j8wl/bojfgpp0k58/UJ5rbrdYFbI2RFT2BXbSQ=", "narHash": "sha256-GFzPxJzTd1rPIVD4IW+GwJlyGwBDV1Tj5FLYwDQQ9sM=",
"owner": "NixOS", "path": "/nix/store/50yickar04m51aqnc43gxf45g2i0n3k9-source",
"repo": "nixpkgs", "type": "path"
"rev": "46821ea01c8f54d2a20f5a503809abfc605269d7",
"type": "github"
}, },
"original": { "original": {
"id": "nixpkgs", "id": "nixpkgs",
@ -31,7 +14,6 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
} }

View file

@ -1,42 +1,50 @@
{ {
description = "A simple command line frontend for OpenRazer"; description = "A simple command line frontend for OpenRazer";
nixConfig.bash-prompt = "\[\\e[1m\\e[32mrzr-develop\\e[0m\]$ "; outputs = { self, nixpkgs }@inputs:
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem
(system:
let let
pkgs = nixpkgs.legacyPackages.${system}; forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.platforms.unix;
nixpkgsFor = forAllSystems (system: import nixpkgs {
inherit system;
});
in in
{ {
# Package packages = forAllSystems (system:
packages.rzr = let
pkgs.python3Packages.buildPythonApplication rec { pkgs = nixpkgsFor.${system};
name = "rzr"; in
{
rzr =
pkgs.python3Packages.buildPythonPackage {
pname = "rzr";
version = "main";
src = self; src = self;
nativeBuildInputs = with pkgs; [
wrapGAppsHook
];
propagatedBuildInputs = with pkgs; [ propagatedBuildInputs = with pkgs; [
python3Packages.colour python3Packages.colour
python3Packages.openrazer python3Packages.openrazer
python3Packages.toml python3Packages.toml
]; ];
}; };
defaultPackage = self.packages.${system}.rzr; default = self.packages.${system}.rzr;
}
);
# Development shell devShells = forAllSystems (system:
devShell = pkgs.mkShell { let
pkgs = nixpkgsFor.${system};
in
{
rzr = pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs; [
python3 python3
python3Packages.colour python3Packages.colour
python3Packages.openrazer python3Packages.openrazer
python3Packages.pip
python3Packages.setuptools
python3Packages.toml python3Packages.toml
python3Packages.virtualenv
]; ];
}; };
default = self.devShells.${system}.rzr;
} }
); );
};
} }

View file

@ -1,2 +0,0 @@
colour
toml

28
bin/rzr → rzr Normal file → Executable file
View file

@ -12,24 +12,6 @@ import toml
import sys import sys
def print_greeter():
"""Print greeter."""
greeter = """ _ _ _
/\ \ /\ \ /\ \
/ \ \ / \ \ / \ \
/ /\ \ \ __/ /\ \ \ / /\ \ \
/ / /\ \_\/___/ /\ \ \ / / /\ \_\
/ / /_/ / /\___\/ / / / / / /_/ / /
/ / /__\/ / / / / / / /__\/ /
/ / /_____/ / / / _ / / /_____/
/ / /\ \ \ \ \ \__/\_\ / / /\ \ \
/ / / \ \ \ \ \___\/ // / / \ \ \
\/_/ \_\/ \/___/_/ \/_/ \_\/
"""
print(greeter)
def error(msg, e=True): def error(msg, e=True):
"""Print error to stderr and exit eventually.""" """Print error to stderr and exit eventually."""
print("ERROR: {}".format(msg), file=sys.stderr) print("ERROR: {}".format(msg), file=sys.stderr)
@ -102,9 +84,9 @@ def apply_device_profile(device_profile):
if "lights" in device_profile: if "lights" in device_profile:
for light in device_profile["lights"]: for light in device_profile["lights"]:
color_tuple = get_color_tuple((device_profile["lights"][light])) color_tuple = get_color_tuple((device_profile["lights"][light]))
device.fx.advanced.matrix[ device.fx.advanced.matrix[lightmap[light][0], lightmap[light][1]] = (
lightmap[light][0], lightmap[light][1] color_tuple
] = color_tuple )
else: else:
device.fx.none() device.fx.none()
@ -214,12 +196,8 @@ def list_profiles():
def main(): def main():
global device_manager, lightmap_directory, profile_directory global device_manager, lightmap_directory, profile_directory
# Print greeter
print_greeter()
# Parse arguments # Parse arguments
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description="A simple command line frontend for OpenRazer.", description="A simple command line frontend for OpenRazer.",

View file

@ -2,11 +2,8 @@ from setuptools import setup
setup( setup(
name="rzr", name="rzr",
version="0.0.1", scripts=["./rzr"],
author="Denis Lehmann", py_modules=[],
author_email="denis@opaque.tech",
scripts=["bin/rzr"],
url="https://git.opaque.tech/denis/rzr",
license="LICENSE", license="LICENSE",
description="A simple command line frontend for OpenRazer", description="A simple command line frontend for OpenRazer",
long_description=open("README.org").read(), long_description=open("README.org").read(),