Giter Site home page Giter Site logo

tp-auto-kbbl's Introduction

⌨️💡 tp-auto-kbbl

ThinkPad Auto Keyboard Backlight

tp-auto-kbbl enables keyboard backlighting whenever you start typing. After typing ends (+ timeout), the backlight turns off automatically. It runs in the background on your Linux laptop and checks for keyboard events (default /dev/input/event3).

It should work on any ThinkPad (tested on a 470s) and probably other laptops as well. Let me know if it runs on your device.

To keep CPU/RAM usage low and portability high, I've used Rust for development. This is my first project with it, so if spot anything weird – or plain wrong – let me know! I'm thankful for any advice.

Warning

tp-auto-kbbl works similar to a keylogger (requires root to capture keyboard events system-wide). Always be sure to check the source code.

Usage

Usage: tp-auto-kbbl [options]

Options:
    -h, --help          prints this help message
    -v, --version       prints the version
    -n, --no-dim        don't dim before bg turns off
    -l, --lazy          don't check actual hw brightness state
    -d, --device        specify the device file
    -b, --brightness    target keyboard brightness (1-2)
    -t, --timeout       time before the bg light turns off

Installation

Download the latest release, or clone and build it yourself.

Copy the binary

sudo cp tp-auto-kbbl /usr/bin/

Try it out

tp-auto-kbbl

# You'll probably get an error like this
thread 'main' panicked at 'Permission denied (os error 13)', src/main.rs:44:74

# Once more as root
sudo tp-auto-kbbl

Input device ID: bus 0x11 vendor 0x1 product 0x1
Evdev version: 10001
Input device name: "AT Translated Set 2 keyboard"
Phys location: isa0060/serio0/input0
Setting brightness to 0

Your backlight should turn off immediately. Try if it turns on when you press any button. If not, check if the input device is correct, you may adjust it via the -d parameter.

Systemd service

# Copy the [unit file](https://raw.githubusercontent.com/saibotd/tp-auto-kbbl/master/tp-auto-kbbl.service)
sudo cp tp-auto-kbbl.service /etc/systemd/system/

# (optional) Check if the parameters are correct
sudo nano /etc/systemd/system/tp-auto-kbbl.service

# Reload daemons
sudo systemctl daemon-reload

# Start the service
sudo systemctl start tp-auto-kbbl

# Check if the service runs fine
sudo systemctl status tp-auto-kbbl

Mär 04 14:02:06 Huffer systemd[1]: Started Auto toggle keyboard back-lighting.
Mär 04 14:02:06 Huffer tp-auto-kbbl[343]: Input device ID: bus 0x11 vendor 0x1 p
Mär 04 14:02:06 Huffer tp-auto-kbbl[343]: Evdev version: 10001
Mär 04 14:02:06 Huffer tp-auto-kbbl[343]: Input device name: "AT Translated Set
Mär 04 14:02:06 Huffer tp-auto-kbbl[343]: Phys location: isa0060/serio0/input0
Mär 04 14:02:07 Huffer tp-auto-kbbl[343]: Setting brightness to 0
Mär 04 14:02:09 Huffer tp-auto-kbbl[343]: Setting brightness to 2
Mär 04 14:02:25 Huffer tp-auto-kbbl[343]: Setting brightness to 0

# Finally enable the service
sudo systemctl enable tp-auto-kbbl

Copyright © 2020 Tobias Duehr

tp-auto-kbbl's People

Contributors

fuzzylitchi avatar saibotd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tp-auto-kbbl's Issues

Config file

As of now, all configuration has to be passed as parameters, which is a problem for packaging. It would be nice to be able to read the config from e.g. /etc/tp-auto-kbbl.conf.

Multiple devices

It might be desirable to "wakeup" the bg-lighting when interacting with other devices than the keyboard itself — the touchpad for instance.

Error when running 'sudo tp-auto-kbbl'

When the command sudo tp-auto-kbbl is ran, the following error is displayed

Input device ID: bus 0x19 vendor 0x0 product 0x1
Evdev version: 10001
Input device name: "Power Button"
Phys location: LNXPWRBN/button/input0
Setting brightness to 0
thread 'main' panicked at 'called Result::unwrap() on an Err value: D-Bus error: The name org.freedesktop.UPower was not provided by any .service files (org.freedesktop.DBus.Error.ServiceUnknown)', src/libcore/result.rs:1188:5
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace.

HP Zbook 14

I am trying to control the keyboard backlight on my Zbook 14.

Evdev version: 10001
Input device name: "AT Translated Set 2 keyboard"
Phys location: isa0060/serio0/input0
Setting brightness to 0
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: D-Bus error: Object does not exist at path “/org/freedesktop/UPower/KbdBacklight” (org.freedesktop.DBus.Error.UnknownMethod)', src/main.rs:135:46
stack backtrace:
   0:     0x55d99046fc3c - <unknown>
   1:     0x55d99048b0bc - <unknown>
   2:     0x55d99046cf85 - <unknown>
   3:     0x55d9904715a0 - <unknown>
   4:     0x55d990471155 - <unknown>
   5:     0x55d990471c54 - <unknown>
   6:     0x55d990471730 - <unknown>
   7:     0x55d9904700e4 - <unknown>
   8:     0x55d990471699 - <unknown>
   9:     0x55d990447441 - <unknown>
  10:     0x55d9904474d3 - <unknown>
  11:     0x55d990449789 - <unknown>
  12:     0x55d990451933 - <unknown>
  13:     0x55d99044fac9 - <unknown>
  14:     0x55d99046f8cb - <unknown>
  15:     0x55d990449ae2 - <unknown>
  16:     0x7f0e114b8b25 - __libc_start_main
  17:     0x55d990447b6e - <unknown>
  18:                0x0 - <unknown>

Can this be done at all if the KbdBacklight object doesn't exit?

FEATURE: Reading the ambient light sensor to set backlight intensity...

Hi,

Would be great to have an option to read the light intensity and set the backlight level accordingly.

In my case the light sensor lives on:

  • ThinkPad X1 Yoga (gen3): /sys/bus/iio/devices/iio:device2/
  • ThinkPad S1 Yoga: /sys/bus/iio/devices/iio:device5/

And since there would be two inputs, it would logical to have an option to chose either one, i.e. ether only use the light sensor or only the input.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.