npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

openrazer-sdk

v1.0.2

Published

Node.js SDK for controlling Razer peripherals via the OpenRazer daemon

Readme

OpenRazer SDK

npm version License: GPL-2.0

用于通过 OpenRazer daemon 控制雷蛇外设的 Node.js SDK。

特性

  • 设备发现 — 自动枚举所有已连接的雷蛇设备
  • 设备控制 — 查询设备信息、功能和当前状态
  • 灯光效果 — 应用呼吸灯、光谱、静态颜色、波浪、自定义 ChromaFX 等效果
  • 原生 D-Bus — 通过 D-Bus 与 openrazer-daemon 直接通信
  • TypeScript — 内置完整类型定义

前置要求

本 SDK 需要系统已安装并运行 OpenRazer。请先参考 OpenRazer 项目 进行安装。

安装 OpenRazer

Ubuntu / Debian:

sudo apt install openrazer-daemon openrazer-driver-manager

Fedora:

sudo dnf install openrazer-daemon python3-openrazer

Arch Linux:

sudo pacman -S openrazer-daemon

安装完成后,请确保 openrazer-daemon 正在运行。

验证 daemon 状态

# 检查 daemon 是否运行
systemctl --user status razerd

# 如果未运行,启动它
systemctl --user start razerd

安装 SDK

npm install openrazer-sdk

快速开始

import { DeviceManager, ChromaFX, SingleLedFX } from 'openrazer-sdk';

// 发现设备
const manager = new DeviceManager();
console.log('发现的设备:', manager.devices.map(d => d.name));

// 获取第一个设备
const device = manager.devices[0];
console.log(`正在控制: ${device.name}`);

// 应用呼吸灯效果 (ChromaFX)
await device.fx.breathSingle(255, 0, 0);

// 应用单 LED 效果
const led = new SingleLedFX(device.devicePath, 'logo');
await led.static(0, 255, 0);

API 概览

DeviceManager

  • devices: Device[] — 所有已发现设备的列表
  • refresh() — 重新扫描设备

Device

  • name: string — 显示名称
  • serial: string — 设备序列号
  • type: string — 设备类型(键盘、鼠标、耳机等)
  • fx: ChromaFX — 设备灯光效果控制器

ChromaFX(通过 device.fx 访问)

  • spectrum() — 光谱循环效果
  • wave(direction) — 波浪效果(0: 从左到右, 1: 从右到左)
  • static(r, g, b) — 静态颜色
  • breathSingle(r, g, b) — 单色呼吸灯
  • breathDual(r1, g1, b1, r2, g2, b2) — 双色呼吸灯
  • breathRandom() — 随机颜色呼吸灯
  • reactive(r, g, b, speed) — 响应式效果
  • ripple(r, g, b, refreshRate) — 涟漪效果
  • rippleRandom(refreshRate) — 随机颜色涟漪
  • none() — 关闭灯光

SingleLedFX

  • new SingleLedFX(devicePath, ledName) — 构造函数,ledName 如 'logo'、'backlight'
  • static(r, g, b) — 静态颜色
  • spectrum() — 光谱循环
  • none() — 关闭灯光
  • getBrightness() / setBrightness() — 亮度控制

示例

更多示例请查看 examples/ 目录:

  • devices.ts — 列出所有设备及其属性
  • chroma-effects.ts — 演示各种 ChromaFX 灯光模式
  • single-led.ts — 控制单独 LED 区域