Skip to content

About

Safe Linux utility for static RGB control of the Dell G16 7620 keyboard

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

Dell G16 7620 keyboard RGB utility

Set static per-key colors on the built-in keyboard of a Dell G16 7620 from Linux. The utility reads one complete color map from the user's XDG config directory and applies it atomically.

The tool supports only the Darfon keyboard with USB ID 0d62:dcbc. It verifies the keyboard's HID descriptor before writing and refuses other devices.

Requirements

  • Linux with hidraw support
  • A C++20 compiler
  • CMake 3.20 or newer
  • Ninja
  • udev with logind for unprivileged access
  • systemd for optional automatic startup

If lsusb is available, you can check the keyboard's USB ID before building:

lsusb -d 0d62:dcbc

No output means this utility does not support the detected keyboard. A matching USB ID is necessary but not sufficient; the utility performs an additional HID descriptor check before applying a color.

Tested system

  • Dell G16 7620 with the 0d62:dcbc Darfon keyboard
  • Manjaro Linux with kernel 6.1.177-3-MANJARO

Install

Build, test, and install the utility for the current user:

cmake -S . -B build -G Ninja \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX="$HOME/.local"
cmake --build build
ctest --test-dir build --output-on-failure
cmake --install build

This installs the executable to ~/.local/bin, generates a user service in ~/.local/share/systemd/user, and creates the initial color map at ~/.config/dell-g16-keyboard-rgb/colors.conf. Reinstalling preserves an existing color map.

Allow access without root

Review and install the narrowly scoped udev rule:

sudo install -o root -g root -m 0644 \
  udev/70-dell-g16-keyboard-rgb.rules \
  /etc/udev/rules.d/70-dell-g16-keyboard-rgb.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --action=change --subsystem-match=hidraw

The utility should then run as the active desktop user. Do not run it with sudo. The uaccess rule may not grant access to an SSH-only session.

Quick start

Edit ~/.config/dell-g16-keyboard-rgb/colors.conf to customize the keyboard. Each key has a six-digit RGB color:

esc=ff5500
f1=c0ffff
h=ff5500

The installed map lists every supported key in keyboard order. The utility rejects missing, duplicate, unknown, or malformed entries instead of applying a partial layout.

Preview the complete map without opening the keyboard:

~/.local/bin/dell-g16-keyboard-rgb

Apply it:

~/.local/bin/dell-g16-keyboard-rgb --apply

Use --config PATH to read the same format from another location. Run ~/.local/bin/dell-g16-keyboard-rgb --help for the complete command shape.

Reapply colors after login

The installed user service reads and applies the color map once when the user session starts. It does not leave a daemon running.

systemctl --user daemon-reload
systemctl --user enable --now dell-g16-keyboard-rgb.service

After editing the color map, apply it immediately with the utility or restart the service:

systemctl --user restart dell-g16-keyboard-rgb.service

The keyboard firmware may replace the color after reboot or suspend. The user service handles a new login, but it does not currently reapply colors after resume from suspend.

Troubleshooting and recovery

If the utility cannot access the keyboard, confirm that lsusb -d 0d62:dcbc finds it, reinstall or retrigger the udev rule, and run the command from an active desktop session. The utility also accepts --device /dev/hidrawN for diagnosis, but still performs every identity check.

If keyboard input ever stops, let the command exit first. If input does not recover, reboot using another input path. Reloading usbhid can also recover it, but a reboot is simpler and avoids disrupting every other USB HID device.

Uninstall

systemctl --user disable --now dell-g16-keyboard-rgb.service
rm -f "$HOME/.local/share/systemd/user/dell-g16-keyboard-rgb.service"
rm -f "$HOME/.local/bin/dell-g16-keyboard-rgb"
systemctl --user daemon-reload

sudo rm -f /etc/udev/rules.d/70-dell-g16-keyboard-rgb.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --action=change --subsystem-match=hidraw

The color map is left in place so an uninstall does not discard customization.

Safety design

  • Without --apply, the utility only prints the exact reports it would send and does not open /dev/hidraw*.
  • Before writing, it verifies both USB IDs and the HID descriptor sequence for report ID 0xcc with its 63-byte payload.
  • It sends only five fixed API-v5 operations: begin transaction (94), status (93), static color (8c 02), end color data (8c 13), and apply (8b 01 ff). The transaction-begin command is a lighting-protocol reset, not a USB, firmware, or machine reset.
  • Key IDs come from a compiled allowlist. There is no raw command option.
  • The color map must define every allowlisted key exactly once.
  • The project has no third-party runtime libraries, network code, fan or power controls, firmware persistence commands, or automatic root escalation.

Development

The protocol tests and dry-run CLI tests do not require keyboard access. To also make compiler warnings fail the build:

cmake -S . -B build -G Ninja \
  -DDELL_G16_KEYBOARD_RGB_WARNINGS_AS_ERRORS=ON
cmake --build build
ctest --test-dir build --output-on-failure

License

MIT

About

Safe Linux utility for static RGB control of the Dell G16 7620 keyboard

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages