Hardware/Razer: Difference between revisions
No edit summary |
m removed unused sudo command in root service |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 8: | 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 59: | 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 | |||
If that does not work, you can reset all usb controllers instead: | |||
https://unix.stackexchange.com/questions/704341/how-to-reset-usb-controllers<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-usb-controller" '' | |||
#!/usr/bin/env bash | |||
# Resets all USB host controllers of the system. | |||
# This is useful in case one stopped working | |||
# due to a faulty device having been connected to it. | |||
base="/sys/bus/pci/drivers" | |||
sleep_secs="1" | |||
# This might find a sub-set of these: | |||
# * 'ohci_hcd' - USB 3.0 | |||
# * 'ehci-pci' - USB 2.0 | |||
# * 'xhci_hcd' - USB 3.0 | |||
echo "Looking for USB standards ..." | |||
for usb_std in "$base/"?hci[-_]?c* | |||
do | |||
echo "* USB standard '$usb_std' ..." | |||
for dev_path in "$usb_std/"*:* | |||
do | |||
dev="$(basename "$dev_path")" | |||
echo " - Resetting device '$dev' ..." | |||
printf '%s' "$dev" | tee "$usb_std/unbind" > /dev/null | |||
sleep "$sleep_secs" | |||
printf '%s' "$dev" | tee "$usb_std/bind" > /dev/null | |||
echo " done." | |||
done | |||
echo " done." | |||
done | |||
echo "done." | |||
''; | |||
KillMode = "process"; | |||
Restart = "on-failure"; | |||
}; | |||
wantedBy = ["graphical.target"]; | |||
}; | |||
systemd.services."usb-reset".enable = true; | |||
</syntaxhighlight> |