The XDG Base Directory specification [1] demands that there should be a
"single base directory relative to which user-specific non-essential
(cached) data should be written". Light currently makes use of such a
cache directory, but hardcodes the default "$HOME/.cache".
In order to enable users to specify a custom cache directory, respect
this convention and use the "$XDG_CACHE_HOME" environment variable if it
is set. If it is not set, fall back to "$HOME/.cache".
[1] https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
Fix #46: Migrate to use ~/.cache/light for unpriviliged operation
When light is installed in the non-SUID root mode it cannot write to
/etc/light anymore, so we set up a ~/.cache/light instead.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Overhaul and simplify program usage and documentation in README
- Use version from configure script
- Simplify usage text for accessibility, only one command at a time
- Simplify terminology, we have commands and options to commands
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Fix different kinds of issues with string buffers and pointers
- Use NAME_MAX and PATH_MAX instead of hardcoded values
- Allow paths to be longer than 256 chars
- Check pointers everywhere
- Use strncpy/snprintf instead of strcpy/sprintf
- Validate controllers' name (-s flag + a very long name -> bad things happening)
- Get rid of globals for dir iteration
Fix wrong behavior of 'light_controllerAccessible'
This function was:
- Reading values from the controller
- Checking write permission even when we just want reading values
- Checking the mincap file instead of the actual controller
The last one is also true for other functions using
'light_getBrightness'.
This commit fixes that.