tweaks + docs...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2024-04-07 00:47:39 +03:00
parent 2bd93f2964
commit 7b8f1db9a5
3 changed files with 47 additions and 9 deletions

View File

@ -1,25 +1,27 @@
SBIN_DIR := /usr/sbin/
NAME := thinkpad-keyboard-brightness
SERVICE_DIR := /etc/systemd/system/
SCRIPT := thinkpad-keyboard-brightness
TIMER := $(SCRIPT).timer
UNIT := $(SCRIPT).service
TIMER := $(NAME).timer
UNIT := $(NAME).service
.PHONY:install
install: $(TIMER) $(UNIT) $(SCRIPT)
cp -f $(UNIT) $(TIMER) $(SERVICE_DIR)
install: $(TIMER) $(UNIT)
cp -f $? $(SERVICE_DIR)
systemctl daemon-reload
systemctl enable ${UNIT}
systemctl enable ${TIMER}
systemctl start ${TIMER}
systemctl start ${UNIT}
.PHONY:disable
disable: $(TIMER) $(UNIT)
systemctl stop ${TIMER}
systemctl stop ${UNIT}
systemctl disable ${TIMER}
systemctl disable ${UNIT}

View File

@ -1 +1,35 @@
# thinkpad-keyboard-brightness
# Thinkpad keyboard backlight brightness
This service will set the keyboard backlight brightness based on ambient
light levels.
## Install
```bash
$ sudo make install
```
## Configure
```bash
$ sudo systemctl edit thinkpad-keyboard-brightness.service
```
Variables that can change depending on device
```
[Service]
Environment=SENSOR=/sys/bus/iio/devices/iio:device2/in_illuminance_raw
Environment=TRIGGER=/sys/class/leds/tpacpi::kbd_backlight/brightness
Environment=THRESHOLD=1500
Environment=VALUE=1
```
## Uninstall
```bash
$ sudo make uninstall
```

View File

@ -4,8 +4,10 @@ Description="Turn keyboard backlight on/off based on light sensor"
[Service]
Type=exec
Environment=SENSOR=/sys/bus/iio/devices/iio:device2/in_illuminance_raw
WorkingDirectory=/sys/class/leds/tpacpi::kbd_backlight/
ExecStart=bash -c "(( $(cat ${SENSOR}) < 1500 )) && echo 1 > brightness || echo 0 > brightness"
Environment=TRIGGER=/sys/class/leds/tpacpi::kbd_backlight/brightness
Environment=THRESHOLD=1500
Environment=VALUE=1
ExecStart=bash -c "(( $(cat ${SENSOR}) < ${THRESHOLD} )) && echo ${VALUE} > ${TRIGGER} || echo 0 > ${TRIGGER}"
[Install]
WantedBy=multi-user.target