GithubHelp home page GithubHelp logo

kira's Introduction

kira

evil light

kira is a script, that disguises itself as an rust application, that can set the brightness of your monitor of your Linux laptop.

The distinguishing feature of kira, the reason I wrote it instead of using alternatives like light or acpilight, which are better in every other respect, is the smooth setting of the brightness.

Brightness is set step-wise over time resulting in a linear and smooth transition of brightness.

Usage

$ kira            # set brightness to 100%
$ kira 33         # set brightness to 33%
$ kira +12        # increase brightness by 10%
$ kira -43        # decrease brightness by 43%

Limitations

  • Works only on specific machines and OSes
    • Linux (sysfs)
    • Intel graphics card
  • No meaningful error handling
  • Interpolation is linear only

How it works

kira writes to the sysfs kernel API of Linux. Specifically, /sys/class/backlight/intel_backlight.

The transition is achieved by looping from the current value until the target value and sleeping the thread for a couple of nanoseconds on each step. This means the transition speed (smoothness) is dependent on the range of values of my specific device and magic amount of nanoseconds I chose.

This happens to work out on my Thinkpad x230, but is unlikely to work universally.

Working together

If for some bizarre reason you have to urge to collaborate in this project, shoot me a mail or open an issue to start discussing ideas.

kira's People

Contributors

bugabinga avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

kira's Issues

Support for all devices under `/sys/class/backlight`

If I understand the sysfs backlight API correctly, the various drivers expose their functionality under /sys/class/backlight/<device_name>/ {brightness,max_brightness}.

There are more files, but only brightness and max_brightness are relevant for kira.

kira should enumerate all devices into a vector.
If a human specifies a device, use that one, otherwise pick the first in the vector.
Devices can be specified by giving their name after the brightness value.

$ kira 44 <device_name>

The device name is fuzzily matched.
No match or an ambiguous match results in an error.

Assuming a machine with 3 backlight devices:

  1. /sys/class/backlight/intel_backlight/
  2. /sys/class/backlight/acpi_backlight/
  3. /sys/class/backlight/acpi_super_backlight/

kira 33 intel uses 1.
kira 33 acpi is an error.
kira 33 acpi_b uses 2.
kira 33 ab uses 2.
kira 33 abs uses 3.

Questions

  • Are the value ranges (min,max) consistent between drivers?
  • What does it mean when there are multiple devices under /sys/class/backlight?
  • Why have I never seen this functionality on desktops? Laptops only?

Decrementing brightness wraps around

When subtracting a value, that exceeds the minimum, the brightness is set to max again.

The value should stay at minimum such that

minimum_brightness - x (>0) = minimum_brightness

Change interpolation to "ease-in"

Currently the brightness changes over time linearly.

The whole purpose of interpolating the change of brightness is to not surprise humans with sudden changes.
Following this logic, an 'ease-in interpolation is ideal because it starts slow.

It is also worth experimenting with ease-in ease-out.
It seems equally appropriate, so I would like to test the difference.

Resources

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.