aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2018-07-11 15:56:07 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2018-07-11 15:56:07 +0800
commite5aac499a8a2026af5d5176f45be3ac2576d75cc (patch)
tree0a8650bc69c21b6bad8f428f8f21fb70b08d2d80
parent0e023a454381cb53147d5394d2de76b79e0816e7 (diff)
downloadlightsd-e5aac499a8a2026af5d5176f45be3ac2576d75cc.tar.xz
Remove profanity.
Reset the iio device buffer before using it.
-rw-r--r--ChangeLog4
-rw-r--r--README.md13
-rw-r--r--brightness_ctrl.cpp5
-rw-r--r--main.cpp2
-rw-r--r--sensors.cpp4
5 files changed, 15 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index f70ae81..2c82fd3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2018-07-11 0.0.5-r1
+Remove profanity.
+Reset the iio device buffer before using it.
+
2018-07-11 0.0.5
Manual mode added.
Quit gracefully.
diff --git a/README.md b/README.md
index 28c6d7c..0916ea4 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
`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!
+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
@@ -18,9 +18,8 @@ The project also demostrates how damn stupid a C++ program could look like
Hopefully it does not yet hog the CPU.
# Warning
-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).
+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!
@@ -102,12 +101,12 @@ action=echo f > /tmp/lightsd.cmd.fifo
# To-do
- Less segmentation faults (already eliminated in my daily usage)
- Less data races (???)
- - Input sanitation (partially)
+ - Input sanitation (partially done)
- 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)
+ screen backlight and keyboard backlight? (will anybody actually use it?)
+ - auto orientation using accelerometer? (otherwise my `Sensor` class is a waste /s)
- hogging cpu and battery? (oh no)
- triggers custom scripts? (detonate your computer once the reading reaches a
certain value?)
diff --git a/brightness_ctrl.cpp b/brightness_ctrl.cpp
index 21c54e7..d83b4cf 100644
--- a/brightness_ctrl.cpp
+++ b/brightness_ctrl.cpp
@@ -70,10 +70,9 @@ void BrightnessControl::set_frozen(bool frozen)
int BrightnessControl::get_offset(){return offset;}
int BrightnessControl::get_brightness()
{
- //FIXME??: On some devices there are EC-controlled key combinations
+ //On some devices there are EC-controlled key combinations
//that bypasses lightsd entirely (e.g. Fn+Space on ThinkPad for
- //keyboard backlight). So we may have to turn to sysfs for this...
- //Screw it, just read from sysfs.
+ //keyboard backlight). So we have to turn to sysfs for the real value...
if(brpath.empty())return 0;
return round(readint(brpath.c_str())*100./maxbr);
}
diff --git a/main.cpp b/main.cpp
index 524682e..e7f4e84 100644
--- a/main.cpp
+++ b/main.cpp
@@ -177,7 +177,7 @@ void command_thread()
printf(manualmode?"ALS value: --\n":"ALS value: %.2f\n",als.get_value());
printf("Display brightness: %d%%",lcd.get_brightness());
if(!manualmode&&lcd.get_offset())printf(" (+%d%%)\n",lcd.get_offset());else putchar('\n');
- //TODO: check for existance
+ //TODO: do not print this if keyboard backlight is not managed
printf("Keyboard backlight: %d%%\n",kbd.get_brightness());
}
if(cav[0]=="q")
diff --git a/sensors.cpp b/sensors.cpp
index 4900957..e1a0694 100644
--- a/sensors.cpp
+++ b/sensors.cpp
@@ -94,7 +94,7 @@ void SensorBase::enable_scan_element(std::string elem)
path elem_type_path=sysfspath/"scan_elements"/(elem_base+"_type");
std::string ts;dict[elem_base+"_type"]=ts=readstr(elem_type_path.c_str());
scan_t st;parse_type_string(ts,&st);
- readsize+=st.storagebits/8;//assume this shit is aligned to byte
+ readsize+=st.storagebits/8;//assume this is aligned to byte
path elem_en_path=sysfspath/"scan_elements"/(elem_base+"_en");
writeint(elem_en_path.c_str(),1);
@@ -126,6 +126,7 @@ bool SensorBase::init(int id,std::string _sensor_basename)
path offset_path=sysfspath/(sensor_basename+"_offset");
dict[sensor_basename+"_offset"]=readfloat(offset_path.c_str());
+ reset();
ignore_result(pipe(qpipe));
enabled_scan_elem.clear();
enable_scan_elements();
@@ -140,7 +141,6 @@ void SensorBase::deinit()
{
if(~devfd)close(devfd);
devfd=-1;
- //...also disable iio buffers?
}
void SensorBase::reset()
{