aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Mykyta Holubakha <hilobakho@gmail.com>2017-09-22 15:59:09 +0300
committerGravatar Mykyta Holubakha <hilobakho@gmail.com>2017-09-22 15:59:09 +0300
commitba070ef1f2eb86fbc4fe396e1267df3905c78cfe (patch)
tree7fe16c0040446b5dcbb92dcc966379c9ca91e744
parent30c94ef6af70d34314bcebfd238363f519192bb5 (diff)
Version bump to 0.3
fixes #10 added an option to install udev rules (fixes #11) updated makefile to adhere to DESTDIR/PREFIX conventions updated README
-rw-r--r--90-brightnessctl.rules4
-rw-r--r--Makefile27
-rw-r--r--README.md16
3 files changed, 32 insertions, 15 deletions
diff --git a/90-brightnessctl.rules b/90-brightnessctl.rules
new file mode 100644
index 0000000..99a4c4d
--- /dev/null
+++ b/90-brightnessctl.rules
@@ -0,0 +1,4 @@
+ACTION=="add", SUBSYSTEM=="backlight", RUN+="/bin/chgrp video /sys/class/backlight/%k/brightness"
+ACTION=="add", SUBSYSTEM=="backlight", RUN+="/bin/chmod g+w /sys/class/backlight/%k/brightness"
+ACTION=="add", SUBSYSTEM=="leds", RUN+="/bin/chgrp input /sys/class/leds/%k/brightness"
+ACTION=="add", SUBSYSTEM=="leds", RUN+="/bin/chmod g+w /sys/class/leds/%k/brightness"
diff --git a/Makefile b/Makefile
index b3986fb..8f23928 100644
--- a/Makefile
+++ b/Makefile
@@ -1,13 +1,28 @@
-VERSION = 0.2
-DESTDIR ?= /usr/local
+VERSION = 0.3
CFLAGS += -std=c99 -g -Wall -Wextra -DVERSION=\"${VERSION}\" -D_POSIX_C_SOURCE=200809L -lm
-MODE ?= 4711
+
+PREFIX ?= /usr
+BINDIR = ${DESTDIR}${PREFIX}/bin
+
+INSTALL_UDEV_RULES = 0
+
+INSTALL_UDEV_1 = install_udev_rules
+UDEVDIR ?= /lib/udev/rules.d
+
+MODE_0 = 4711
+MODE_1 = 0644
+MODE = ${MODE_${INSTALL_UDEV_RULES}}
all: brightnessctl
-install: brightnessctl
- install -d ${DESTDIR}/bin
- install -m ${MODE} brightnessctl ${DESTDIR}/bin/
+install: brightnessctl ${INSTALL_UDEV_${INSTALL_UDEV_RULES}}
+ install -d ${DESTDIR}${PREFIX}/bin
+ install -m ${MODE} brightnessctl ${DESTDIR}${PREFIX}/bin/
+
+install_udev_rules:
+ install -d ${DESTDIR}${UDEVDIR}
+ install -m 0644 90-brightnessctl.rules ${DESTDIR}${UDEVDIR}
+
clean:
rm -f brightnessctl
diff --git a/README.md b/README.md
index 5aaa3ce..7b81757 100644
--- a/README.md
+++ b/README.md
@@ -10,19 +10,17 @@ The program is available in:
* [Fedora/EPEL](https://apps.fedoraproject.org/packages/brightnessctl)
* [Arch Linux (AUR)](https://aur.archlinux.org/packages/brightnessctl)
+One can build and install the program using `make install`. Consult the Makefile for relevant build-time options.
+
## Permissions
-Modifying brightness requires write permissions for device files. This can be accomplished (without using sudo/su/etc.) by either of the following means:
+Modifying brightness requires write permissions for device files. `brightnessctl` accomplishes this (without using `sudo`/`su`/etc.) by either of the following means:
-1) installing brightnessctl as a suid binary (done by default)
+1) installing `brightnessctl` as a suid binary (done by default)
-2) adding a similar udev rule (assuming your user is in `video` group for backlight and `input` group for leds):
-```
-ACTION=="add", SUBSYSTEM=="backlight", RUN+="/bin/chgrp video /sys/class/backlight/%k/brightness"
-ACTION=="add", SUBSYSTEM=="backlight", RUN+="/bin/chmod g+w /sys/class/backlight/%k/brightness"
-ACTION=="add", SUBSYSTEM=="leds", RUN+="/bin/chgrp input /sys/class/leds/%k/brightness"
-ACTION=="add", SUBSYSTEM=="leds", RUN+="/bin/chmod g+w /sys/class/leds/%k/brightness"
-```
+2) installing relevant udev rules to add permissions to backlight class devices for users in `video` and leds for users in `input`.
+
+The behavior is controlled by the `INSTALL_UDEV_RULES` flag (setting it to `1` installs the udev rules, `0` is the default value).
## Usage
```