#backlight #utils #cli

bin+lib backlight_control_rs

Backlight control is a re-written version of backlight_control with a few key improvements

1 stable release

1.0.0 Dec 1, 2024

#444 in Filesystem

Download history 61/week @ 2024-11-25 63/week @ 2024-12-02 7/week @ 2024-12-09

131 downloads per month

MIT/Apache

14KB
156 lines

backlight_control_rs

Static Badge Dynamic TOML Badge

Backlight control is a re-written version of backlight_control with a few key improvements.

Why re-write this?

There are a few reasons:

  1. The original backlight_control sets the backlight dir at compile time in the make file. The problem with this is that it makes it impossible to be cached in package repositories. backlight_control_rs determines this information at runtime, meaning caching is possible.

  2. backlight_control_rs comes with a library, so that other projects can easily adjust the backlight brightness as well.

  3. backlight_control_rs has made a few QOL changes compared to the original: better help message, --stats option, absolute and relative adjustments

  4. backlight_control doesn't work on NixOs due to how it's written. backlight_control_rs addresses this.

Why use this over something like light?

light is also a good alternative, however I personally very much enjoyed the high degree of simplicity of backlight_control. Light offers many more features than I ever needed, hence backlight_control was the clear choice. It did what I needed and nothing more.

And backlight_control_rs has all the simplicity of backlight_control, without any of the troubles.

As for other options, they either fall into the same category as light in having too much, or needing X-server to work.

Usage

backlight_control_rs +50 # increase brightness by 50
backlight_control_rs -50 # reduce brightness by 50
backlight_control_rs 50 # set brightness to 50

NOTE: These values are absolute. They do not adjust as n% as with backlight_control. To do this, append a %:

backlight_control_rs +50% # increase brightness by 50%
backlight_control_rs -50% # reduce brightness by 50%
backlight_control_rs 50% # set brightness to 50%

You can run with -s to print information about the backlight, rather than making adjustments.

Installing

You can use cargo install, however, this method is less desirable than installing via your package manager.

Nix / NixOs

WIP

AUR

WIP

Note on permissions

The original backlight_control used permissions to allow anyone to run the binary as root. This made it possible to change the backlight brightness without any further configuration. This approach doesn't work on NixOs however, since files in /nix/store can't have their permissions set in this way.

The solution: udev rules

This is what most other programs do to handle this issue.

By using a udev rule to change the ownership of the brightness file to the video group any user in that group, can change the backlight brightness.

This is also the reason why you should use a package manager rather than cargo install, sine the permissions won't be handled for you.

License

This project is licensed under either of

at your option.

Its inspiration comes in no small part from backlight_control and light.

Dependencies

~3.5–5MB
~86K SLoC