Jump to content

Hardware/Razer: Difference between revisions

Add razer usb reset.
imported>AmnesiaAmesia
m (Added texts about how to enable openrazer with frontend)
(Add razer usb reset.)
 
(5 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Hardware/breadcrumb}}
<h2>OpenRazer</h2>
<h2>OpenRazer</h2>
OpenRazer is an open-source project to support Razer peripherals, including those found in their laptops. To enable the OpenRazer you need to add the following to your <code>configuration.nix</code>
OpenRazer is an open-source project to support Razer peripherals, including those found in their laptops. To enable the OpenRazer you need to add the following to your <code>configuration.nix</code>
Line 7: Line 8:
       openrazer-daemon
       openrazer-daemon
   ];
   ];
</syntaxHighlight>
To run the <code>openrazer-daemon</code>, you need to be in the <code>openrazer</code> group.
<syntaxHighlight lang=nix>
users.users.<username> = { extraGroups = [ "openrazer" ]; };
</syntaxHighlight>
</syntaxHighlight>


Line 22: Line 28:
Upon closing the lid to the laptop and reopening, an issue occurs where the device will intermittently go back into hybernate mode after around 10-30 seconds. Setting the kernel parameter <code>button.lid_init_state=open</code> fixes this issue. The following is an example configuration (working in NixOS 22.05):
Upon closing the lid to the laptop and reopening, an issue occurs where the device will intermittently go back into hybernate mode after around 10-30 seconds. Setting the kernel parameter <code>button.lid_init_state=open</code> fixes this issue. The following is an example configuration (working in NixOS 22.05):


<syntaxHighlight lang=nix>
   boot.kernelParams = [ "button.lid_init_state=open" ];
   boot.kernelParams = [ "button.lid_init_state=open" ];
</syntaxHighlight>


<h3>Getting the Nvidia card to work properly with external displays</h3>
<h3>Getting the Nvidia card to work properly with external displays</h3>
Line 28: Line 36:
In order to get both the laptop display and external displays working, in the BIOS settings set Chipset > GPU MODE to "Dedicated GPU only".
In order to get both the laptop display and external displays working, in the BIOS settings set Chipset > GPU MODE to "Dedicated GPU only".


After setting the GPU MODE to "Dedicated GPU only" in the BIOS, enabling [https://nixos.wiki/wiki/Nvidia#sync_mode sync mode] is necessary in order for both the laptop's display and external display/ports to work properly. Here is an example configuration snippet for NixOS 22.05:
After setting the GPU MODE to "Dedicated GPU only" in the BIOS, enabling [[Nvidia#sync_mode sync mode| Nvidia]] is necessary in order for both the laptop's display and external display/ports to work properly. Here is an example configuration snippet for NixOS 22.05:


<syntaxHighlight lang=nix>
   services.xserver = {
   services.xserver = {
     videoDrivers = [ "nvidia" ];
     videoDrivers = [ "nvidia" ];
Line 45: Line 54:
     };
     };
   };
   };
</syntaxHighlight>




Line 54: Line 64:


https://wiki.archlinux.org/title/Razer_Blade
https://wiki.archlinux.org/title/Razer_Blade
<h2>Updating your system to use the unstable drivers and daemon</h2>
If you are using a new model from razer it probably is not available in the stable packages.
But it might be available in the unstable ones.
In your configuration.nix file:
<syntaxHighlight lang=nix>
nixpkgs.config = {
    allowUnfree = true;
    packageOverrides = pkgs: {
      stable = import <nixos-stable> {config = config.nixpkgs.config;};
      unstable = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz") { config = config.nixpkgs.config; };
    };
  };
# updates the whole kernel to unstable so you have the correct drivers.
boot.kernelPackages = pkgs.unstable.linuxPackages;
# overrides the openrazer-daemon that the harware.openrazer.enable starts
  nixpkgs.overlays = [
    (final: prev: {
      openrazer-daemon = pkgs.unstable.openrazer-daemon;
    })
  ];
  environment.systemPackages = with pkgs; [
    unstable.polychromatic
# alternatively
#    unstable.razergenie
  ];
</syntaxHighlight>
== USB disable Issues ==
If you are encountering issues that your Razer keyboard does light up on boot shortly and then can not be found by the open-razer-daemon until you unplug your USB cable and re-plug it. Then you might want to reset your USB on startup so that after login the daemon finds it again.<syntaxhighlight lang="nixos" line="1">
  # Razer usb reset. Since it disables somehow on boot.
  systemd.services."usb-reset" = {
    description = "Resets usb port for my Razer Keyboard";
    after = ["multi-user.target"];
    serviceConfig = {
        User = "root";
        Type = "simple";
        ExecStart=pkgs.writeShellScript "unit-restart-usb7_3" ''
          echo '7-3' |tee /sys/bus/usb/drivers/usb/unbind
          echo '7-3' |tee /sys/bus/usb/drivers/usb/bind
        '';
        KillMode = "process";
        Restart = "on-failure";
    };
    wantedBy = ["graphical.target"];
  };
  systemd.services."usb-reset".enable = true;
</syntaxhighlight>7-3 is the Bus: 7 and the Port: 3
How to figure those out you can read here:
https://superuser.com/questions/1707773/how-to-turn-usb-connected-device-on-and-off-in-linux
2

edits