diff options
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 84 |
1 files changed, 56 insertions, 28 deletions
@@ -1,11 +1,11 @@ # lightsd -`lightsd` is a small daemon to make your ~~(actually, my)~~ ambient -light sensor on your laptop useful in Linux <sup>interjection</sup> +`lightsd` is a small daemon to make the ambient light sensor on your +~~(actually, my)~~ laptop useful in Linux <sup>interjection</sup> without using a full desktop environment (or `systemd`). It even works in a tty! -This service watches the readings from the ambient light sensor and +This service watches the reading from the ambient light sensor and control the backlight of the screen and keyboard. It also creates a fifo so that you can adjust relative brightness of the lcd. @@ -18,8 +18,9 @@ The project also demostrates how damn stupid a C++ program could look like Hopefully it does not yet hog the CPU. # Warning -WIP. Does not yet do any kind of input sanitation. May segmentation fault -at any time. The author uses Gentoo. _Very_ shitty code. +WIP. May segmentation fault at any time. The author uses Gentoo. _Very_ +shitty code (I admit my code style is crap). The implementation is shitty +too (it works nevertheless). As this daemon manipulates sysfs, IT ONLY RUNS AS ROOT! @@ -32,33 +33,33 @@ Just `mkdir build && cd build && cmake .. && make`. # Installing `sudo make install`. If you are using `OpenRC`, an init script is also installed. -Sorry to `systemd` users but my only computer running `systemd` does not have -iio sensors. +Sorry to `systemd` users but my only computer with iio sensors is not powered by +that. # Documentation -None. The code documents itself. +None. The code documents itself (in a bad way). ## fifo usage - `u [x=5,0<x<=100]` -Makes lcd x% brighter. +Makes lcd x% brighter. ([U]p) - `d [x=5,0<x<=100]` -Makes lcd x% darker. +Makes lcd x% darker. ([D]own) - `s <x,-100<=x<=100>` -Sets relative brightness of lcd. +[S]ets relative brightness of lcd. - `r` -Resets relative brightness of lcd, equivalent to `s 0`. +[R]esets relative brightness of lcd, equivalent to `s 0`. - `f` -Forces an adjustment to be made. You may want to call this when the lid +[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. - -Not implemented: - `m` -Disables automatic brightness. (\_M\_anual) -Some of the commands (r/s/f) does nothing in manual brightness mode. +Disables automatic brightness. ([M]anual) +Some of the commands (`r`/`f`) does nothing in manual mode. +Command `s` sets absolute brightness in manual mode. - `a` -Enables automatic brightness. +Enables [a]utomatic brightness. - `i` -Print current status to stdout. Example output: +Print current status to stdout. ([I]nfo) +Output is in the following format: ``` Mode: <Automatic|Manual> ALS value: <%f|--> @@ -73,13 +74,40 @@ Surprise! # Tested on - Lenovo ThinkPad X1 Yoga 1st gen. +# Integration +Take `acpid` as an example. + +`/etc/acpi/events/brightness-down`: +``` +event=video/brightnessdown +action=echo d 5 > /tmp/lightsd.cmd.fifo +``` + +`/etc/acpi/events/brightness-up`: +``` +event=video/brightnessup +action=echo u 5 > /tmp/lightsd.cmd.fifo +``` + +If your laptop turns keyboard backlight automatically when closing the lid, +you may also want the following: + +`/etc/acpi/events/lid-open`: +``` +event=button/lid.*open +action=echo f > /tmp/lightsd.cmd.fifo +``` + # To-do - - Less segmentation faults - - Less data races - - Input sanitation - - Actual, _real_ logging: not printf'ing to `stdout`. - - More fifo commands: disabling auto adjustment, set absolute brightness etc. - - use iio triggers instead? - - auto orientation using accelerometer? - - hogging cpu and battery? - - ability to embed an email client and to order pizza? + - Less segmentation faults (already eliminated in my daily usage) + - Less data races (???) + - Input sanitation (partially) + - Actual, _real_ logging: not printf'ing to `stdout`. (probably done) + - More commands: disabling auto adjustment, set absolute brightness etc. (done) + - Change configuration format so that one can control something other than + screen backlight and keyboard backlight? (does anybody actually use it?) + - auto orientation using accelerometer? (otherwise my `Sensor` class is a waste) + - 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) |