Add vrgb cycle command for software rainbow cycling - #8
Open
MHS-20 wants to merge 1 commit into
Open
Conversation
MHS-20
force-pushed
the
add-cycle-command
branch
from
September 6, 2026 19:47
bc8d464 to
3fcc786
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
vrgb cycle [percent] [period_seconds] [fps]command that smoothly sweeps the full color spectrum via the existing HID color path (set_color/set_firmware_mode), with adjustable brightness, cycle duration, and frame rate.rainbow, this works on every currently supported device — it doesn't depend on OEM firmware rainbow support (rainbow_supported: Falsedevices, e.g. the0x5570mapping, are unaffected) — and doesn't require sudo, since it stays entirely on the HID color pathset/brightnessalready use.OSErrorif the hidraw node briefly disappears or re-enumerates (observed around suspend/resume), instead of crashing and leaving the keyboard stuck on whatever color it was mid-cycle.Why
I wanted a smooth, speed-adjustable rainbow effect and ran a standalone script driving the hidraw device directly to prototype it. That worked, but died the first time the laptop suspended (unhandled
OSErrorwhen the hidraw node vanished/re-enumerated around the suspend transition — confirmed viajournalctl, the process had run cleanly for over an hour before dying exactly whenomarchy-sleep-lock.servicefired). Folding the fixed version intovrgbitself ascycle, reusing the project's ownfind_device/set_color/set_firmware_mode, seemed more useful than keeping it as an out-of-tree script, and it directly follows from therainbow/autocommands already in the file.Implementation notes
time,colorsys) added to the existing imports.sys.argvparsing (no argparse) with optional trailing positional args, same pattern ascmd_set(cfg, devinfo, color, percent=None);die()for user-facing errors;debug()tracing hooks throughout.save_config) while cycling, since the color is constantly changing and there's no single "current color" worth persisting — this mirrors howoff/restoretreat state, but a continuously-running effect doesn't fit that model.Ctrl+C(KeyboardInterruptcaught, prints "Stopped cycling." and exits 0); for continuous background operation the README's new section for this command points at a process supervisor (e.g. a systemd--userservice — see the separate PR for a relatedvrgb-restore.serviceexample).Featureslist, newCommand Listentry with a worked example, and a short note on the recovery behavior and how it differs fromrainbow.System tested on
ITE5570:00 0B05:19B6,HID_ID=0018:00000B05:000019B6(the primary mapping inSUPPORTED_DEVICES)x86_64,#1 SMP PREEMPT_DYNAMIC)4.0.0.r2015.g4930677--usersession management (uwsm)mise-managed interpreter, not the system Python — confirms no reliance on system-Python-only stdlib behavior)asus-nb-wmikernel module loaded (required for this device per the existingrequired_modulesmapping)Testing performed
All tests run directly against the modified
vrgb.py(invoked aspython3 vrgb.py ...from a working copy, group-permissioned via the existingvrgbudev rule/group from a prior install):python3 -m py_compile vrgb.py— clean compile, no syntax errors.vrgb cyclewith no arguments: usescfg["percent"], 6s period, 20 fps defaults; observed smooth color sweep on the physical keyboard.vrgb cycle 100 2(fast 2s period) andvrgb cycle 50 3 10(custom brightness/period/fps): correct clamping and frame timing confirmed via--debugoutput (hid_set_featurecalls showing the expected RGB progression, e.g.255,7,0→255,33,0→ … around the hue wheel).--debugmode —python3 vrgb.py --debug cycle 50 3 10: confirmed device selection log (exact HID_ID match), report IDs (firmware=0x0B color=0x05), and per-framehid_set_feature/set_colortraces.Ctrl+C/SIGINT) — verified viatimeout --signal=INT --preserve-status: process exits 0 and printsStopped cycling.; also verified interactively with a backgrounded process andkill -INT.vrgb cycle 100 0→Error: period must be greater than 0(exit 1)vrgb cycle 100 abc→Error: period and fps must be numbers(exit 1)vrgb cycle 150→ percent silently clamped to 100 via existingclamp()helper, no crashvrgb cyclein the background (--debug, logging to file), confirmed continuoushid_set_featurewrites, then physically suspended and resumed the laptop (systemctl suspendequivalent via lid/power). Process (checked viapgrep) survived and kept writing colors afterward — this is the scenario that crashed the earlier unpatched prototype, and it did not crash here.cycle/recovery bug) that was diagnosed and resolved separately.Not tested: the
0018:00000B05:00005570(0x5570) device mapping — I don't have that hardware. Thecyclecommand doesn't touch any device-specific behavior beyond the existingfirmware_report_id/color_report_idfields already used byset/brightness/auto, which are exercised identically regardless of mapping, so I'd expect it to work there too, but can't confirm firsthand.