now working...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2024-04-07 00:30:23 +03:00
parent a235ec7504
commit 2bd93f2964
3 changed files with 32 additions and 13 deletions

View File

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

View File

@ -1,12 +1,12 @@
[Unit]
Description="Turn keyboard backlight on/off bases on light sensor"
Description="Turn keyboard backlight on/off based on light sensor"
[Service]
Type=oneshot
RemainAfterExit=yes
Environment="SENSOR=/sys/bus/iio/devices/iio::device2/in_illuminance_raw"
WorkingDirectory=/sys/class/leds/dell::kbd_backlight/
ExecStart=bash -c "[[ $(cat ${SENSOR}) < 1500 ]] && echo 1 > brightness || echo 0 > brightness"
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"
[Install]
WantedBy=multi-user.target

View File

@ -1,5 +1,5 @@
[Unit]
Description="Turn keyboard backlight on/off bases on light sensor (timer)"
Description="Turn keyboard backlight on/off based on light sensor (timer)"
[Timer]
AccuracySec=1s