diff --git a/LICENSE b/LICENSE index 2324481..d449d3e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021 Denis Lehmann +Copyright (c) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.org b/README.org index 3543529..71e274e 100644 --- a/README.org +++ b/README.org @@ -1,6 +1,6 @@ * rzr - #+begin_example + #+begin_src text _ _ _ /\ \ /\ \ /\ \ / \ \ / \ \ / \ \ @@ -12,7 +12,7 @@ / / /\ \ \ \ \ \__/\_\ / / /\ \ \ / / / \ \ \ \ \___\/ // / / \ \ \ \/_/ \_\/ \/___/_/ \/_/ \_\/ - #+end_example + #+end_src *rzr* is a simple command line frontend for [[https://openrazer.github.io/][OpenRazer]]. It allows to set static lighting profiles of Razer devices, based on configuration files. @@ -28,7 +28,9 @@ All you have to do to apply the profile is to execute the following command: - : $ rzr fps + #+begin_src sh + rzr fps + #+end_src The WASD keys get now lighted accordingly. @@ -53,19 +55,25 @@ This project is a [[https://nixos.wiki/wiki/Flakes][Nix flake]]. If you are running a recent version of the [[https://nixos.org/][Nix]] package manager and have flakes enabled, you can execute it with: - : $ nix run github:Deleh/rzr + #+begin_src sh + nix run github:Deleh/rzr + #+end_src On legacy systems you need to make sure the [[https://github.com/openrazer/openrazer/tree/master/pylib][Python libraries]] for OpenRazer are in your path, then clone this repository and execute: - : $ python setup.py install + #+begin_src sh + python setup.py install + #+end_src Or make sure the requirements in =requirements.txt= are fulfilled and call the program directly with: - : $ python bin/rzr + #+begin_src sh + python bin/rzr + #+end_src ** Usage - #+begin_example + #+begin_src text usage: rzr [-h] [-ld LIGHTMAP_DIRECTORY] [-pd PROFILE_DIRECTORY] [COMMAND] Set color profiles of your Razer devices. @@ -84,7 +92,7 @@ path to directory with lightmaps (default: ~/.config/rzr/lightmaps) -pd PROFILE_DIRECTORY, --profile-directory PROFILE_DIRECTORY path to directory with profiles (default: ~/.config/rzr/profiles) - #+end_example + #+end_src If no command is given and the profile =default= exists, it is applied. @@ -173,7 +181,9 @@ On the bottom of the /General/ section is a text field, labeled /launch options/. Insert the following command: - : rzr my_favourite_game & %command%; rzr + #+begin_src sh + rzr my_favourite_game & %command% && rzr || rzr + #+end_src The first command applies the profile =my_favourite_game= as usual. =&= ensures that the next command is called even if the first one failed. @@ -181,7 +191,10 @@ Steam then substitutes the =%command%= part with the binary of the game and runs it. - The =;= waits until the game exited and the =rzr= command finally applies your =default= profile. + The =&&= waits until the first command exited correctly, speaking you quit the game. + If this is the case, the command =rzr= applies your =default= profile. + + In the case of a game crash, the =|| rzr= part makes sure your =default= profile gets applied anyway. It is neccessary that *rzr* is installed correctly and available in your =$PATH=, otherwise Steam will not be able to call it. @@ -191,10 +204,14 @@ If this is the case and you still have problems, stop the daemon with the following command: - : $ systemctl --user stop openrazer-daemon.service + #+begin_example sh + systemctl --user stop openrazer-daemon.service + #+end_example Then run it manually and check the output: - : $ openrazer-daemon -Fv + #+begin_src sh + openrazer-daemon -Fv + #+end_src If it complains about a missing config file, put [[https://github.com/openrazer/openrazer/blob/master/daemon/resources/razer.conf][this]] file in the =~/.config/openrazer= directory and restart the daemon. diff --git a/bin/rzr b/bin/rzr index c325064..bf2d71e 100644 --- a/bin/rzr +++ b/bin/rzr @@ -213,7 +213,7 @@ def list_profiles(): print("No profiles available") -def main(): +if __name__ == "__main__": global device_manager, lightmap_directory, profile_directory @@ -295,7 +295,3 @@ def main(): iterate_lights() elif args.command: apply_profile(args.command) - - -if __name__ == "__main__": - main() diff --git a/flake.lock b/flake.lock index c46589a..c2212f4 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "flake-utils": { "locked": { - "lastModified": 1638122382, - "narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=", + "lastModified": 1619345332, + "narHash": "sha256-qHnQkEp1uklKTpx3MvKtY6xzgcqXDsz5nLilbbuL+3A=", "owner": "numtide", "repo": "flake-utils", - "rev": "74f7e4319258e287b0f9cb95426c9853b282730b", + "rev": "2ebf2558e5bf978c7fb8ea927dfaed8fefab2e28", "type": "github" }, "original": { @@ -17,11 +17,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1642069818, - "narHash": "sha256-666w6j8wl/bojfgpp0k58/UJ5rbrdYFbI2RFT2BXbSQ=", + "lastModified": 1619637108, + "narHash": "sha256-0wlyFJIooxYoA1vgUMeClLkz+OBLbFZZQmzJqyVC3rQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "46821ea01c8f54d2a20f5a503809abfc605269d7", + "rev": "56d46af5d0a7746cf85351536238c1cb0f32a844", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index d2c4c05..b820025 100644 --- a/flake.nix +++ b/flake.nix @@ -1,41 +1,55 @@ { - 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\]$ "; + inputs.flake-utils.url = "github:numtide/flake-utils"; + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; in { + # Package + packages.rzr = + pkgs.python3Packages.buildPythonApplication rec { + name = "rzr"; src = self; + nativeBuildInputs = with pkgs; [ wrapGAppsHook ]; + propagatedBuildInputs = with pkgs; [ python3Packages.colour python3Packages.openrazer python3Packages.toml ]; + }; + defaultPackage = self.packages.${system}.rzr; # Development shell + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ python3 + python3Packages.pip + python3Packages.virtualenv python3Packages.colour python3Packages.openrazer - python3Packages.pip - python3Packages.setuptools python3Packages.toml - python3Packages.virtualenv ]; + }; } ); diff --git a/setup.py b/setup.py index 5554b5f..6c3667d 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( scripts=["bin/rzr"], url="https://git.opaque.tech/denis/rzr", license="LICENSE", - description="A simple command line frontend for OpenRazer", + description="A simple command line frontend for OpenRazer.", long_description=open("README.org").read(), install_requires=["colour", "openrazer", "toml"], )