lightsd is a small daemon to make the ambient light sensor on your
(actually, my) laptop useful in Linux interjection
without using a full desktop environment (or
systemd). It even works
in a framebuffer console!
This daemon watches the reading from the ambient light sensor and controls the backlight of the screen and keyboard. It also creates a fifo so that you can adjust relative brightness of the screen.
It only supports sensors using the industrial I/O bus. It has a generic class for working with many types of iio devices though.
The project also demostrates how damn stupid a C++ program could look like (not yet to its maximum extent).
Hopefully it does not yet hog the CPU.
Alpha quality. May segmentation fault at any time. Featuring my terrible code style. Ugly implementation (it works nevertheless).
As this daemon manipulates sysfs, IT ONLY RUNS AS ROOT!
Do not use
lightsd with GNOME. It has good chance to conflict with GNOME's
- gcc 8.x or clang 6 with C++17 support
mkdir build && cd build && cmake .. && make.
sudo make install. If you are using
OpenRC, an init script is also installed.
systemd users but my only computer with iio sensors is not powered by
None. The code documents itself (in a bad way).
Makes lcd x% brighter. ([U]p)
Makes lcd x% darker. ([D]own)
[S]ets relative brightness of lcd.
[R]esets relative brightness of lcd, equivalent to
[F]orces an adjustment to be made. You may want to call this when the lid is being opened in order to turn on the keyboard backlight.
Disables automatic brightness. ([M]anual)
Some of the commands (
f) does nothing in manual mode. Command
ssets absolute brightness in manual mode.
Enables [a]utomatic brightness.
Print current status to stdout. ([I]nfo)
Output is in the following format:
Mode: <Automatic|Manual> ALS value: <%f|--> Display brightness: %d%% [(+%d%%)] Keyboard backlight brightness: %d%%
The fifo is owned by
root:video and has permission
0220 so that
everyone in the video group could potentially mess with your brightness.
- Lenovo ThinkPad X1 Yoga 1st gen.
acpid as an example.
event=video/brightnessdown action=echo d 5 > /tmp/lightsd.cmd.fifo
event=video/brightnessup action=echo u 5 > /tmp/lightsd.cmd.fifo
If your laptop turns keyboard backlight off automatically when closing the lid (which I believe is what most laptops do), you may also want the following to turn it back on when you open the lid:
event=button/lid.*open action=echo f > /tmp/lightsd.cmd.fifo
- Less segmentation faults (already eliminated in my daily usage)
- Less data races (???)
- Input sanitation (partially done)
- Actual, real logging: not printf'ing to
stdout. (probably done)
- More commands: disabling auto adjustment, set absolute brightness etc. (done)
- D-Bus interface?
- Change configuration format so that one can control something other than screen backlight and keyboard backlight? (will anybody actually use it?)
- auto orientation using accelerometer? (otherwise my
Sensorclass is a waste /s)
- hogging cpu and battery? (oh no)
- triggers custom scripts? (detonate your computer once the reading reaches a certain value?)
- ability to embed an email client and to order pizza? (not happening)