A tiny utility for controlling the ThinkLight on ThinkPad laptops in Haiku OS.
It talks to the ACPI firmware through the /dev/acpi/call device of Haiku,
so no driver is needed.
thinklight 1 light on
thinklight 0 light off
thinklight -64_12-8 blink a pattern
A pattern is a sequence of segments: -N keeps the light on for N ticks,
_N keeps it off for N ticks. One tick is 1/16 of a second, so the example
above is on for 4 s, off for 0.75 s, on for 0.5 s, off for 1/16 s.
The pattern is played once and the light is turned off afterwards. Ctrl+C
during a pattern turns the light off and exits.
g++ -Wno-multichar -O2 -o thinklight thinklight.cpp
- Tested on a ThinkPad T60 (x86_gcc2 and x86_64 Haiku). Other models with a ThinkLight may work, since the same CMOS commands are used by other ThinkPad drivers, but this is not verified.
- The light is switched with the ACPI method
\UCMS(commands0x0Cand0x0D). On a machine without this method the kernel still reports success, so the program silently does nothing. - The
ioctlinterface of/dev/acpi/callis not part of the public Haiku headers. The structures are copied from the Haiku source (src/add-ons/kernel/bus_managers/acpi/Call.cpp) and may change in a future release.
MIT, see LICENSE.