#keyboard #control #command-line #script #api #status #keymapp

build kontroll

Kontroll 连接到 Keymapp API,允许程序化控制 ZSA 键盘

2 个稳定版本

1.0.3 2024年7月30日

#192 in 构建工具

Download history 250/week @ 2024-07-28 4/week @ 2024-08-04

254 每月下载量

MIT 许可协议

140KB
668 代码行

Kontroll

Kontroll 展示了如何控制 Keymapp API,使您能够轻松从命令行和脚本中控制 ZSA 键盘。您可以在我们的博客上了解更多信息:我们的博客

您可以使用它来切换层,并通过 Keymapp 程序化控制键盘的 RGB 和状态 LED。从脚本中调用它,使您的 ZSA 键盘能够以有用的方式对系统事件做出反应(例如,在应用程序激活时切换层,或在收到重要电子邮件时更改照明等)。

注意:Kontroll 的所有功能均适用于 Moonlander 和 Voyager。由于 ErgoDox EZ 使用不同的处理器(Teensy),因此仅有一些功能适用于 ErgoDox EZ。您可以使用 Kontroll 切换层(这是真正关键的部分)和设置状态 LED,但您将无法控制 ErgoDox EZ 的 RGB LED。

请随时通过 示例目录 提交使用 Kontroll 的脚本作为拉取请求。

安装

如果您已安装 rust 工具链和 protoc,则可以通过克隆此仓库并运行以下命令来构建 Kontroll

cargo build --release

否则,您可以从 发布页面 下载最新版本并将其添加到您的 PATH。

先决条件

确保您正在运行最新版本的 Keymapp(v1.3.1+),并且已将 ZSA 键盘连接到计算机。在 Keymapp 的配置页面中,请确保 API 已启用。

在 Linux 和 macOS 上,keymapp create 创建一个位于 $CONFIG_DIR/.keymapp/keymapp.sock 的 Unix 域套接字。

在Windows上,默认情况下,API监听端口号为50051。如果您已在keymapp的设置UI中更改了端口号,您可以通过设置环境变量KEYMAPP_PORT来指定Kontroll使用的端口号。

使用方法

Usage: kontroll <COMMAND>

Commands:
  status               Get the status of the currently connected keyboard
  list                 List all available keyboards
  connect              Connect to a keyboard given the index returned by the list command
  connect-any          Connect to the first keyboard detected by keymapp
  set-layer            Set the layer of the currently connected keyboard
  set-rgb              Sets the RGB color of a LED
  set-rgb-all          Sets the RGB color of all LEDs
  restore-rgb-leds     Restores the RGB color of all LEDs to their default
  set-status-led       Set / Unset a status LED
  restore-status-leds  Restores the status of all status LEDs to their default
  increase-brightness  Increase the brightness of the keyboard's LEDs
  decrease-brightness  Decrease the brightness of the keyboard's LEDs
  disconnect           Disconnect from the currently connected keyboard
  help                 Print this message or the help of the given subcommand(s)

Options:
  -h, --help     Print help
  -V, --version  Print version

示例

示例中展示了如何使用此API。在安装了rust工具链的情况下运行以下命令以运行示例:

cargo run --release --example snake

开发

我们开发了Kontroll来展示Keymapp API,并提供了一种简单的方式从命令行和脚本中控制您的ZSA键盘。

如果您想构建自己的客户端,您需要使用gRPC实现Keymapp API。在此处提供的protobuf文件描述了所有可用的远程调用过程和消息。

如何在api.rs文件中实现每个过程调用的示例可以在api.rs文件中找到。

依赖项

~6–20MB
~234K SLoC