Library and script for changing brightness on Linux via acpi. Allows for easing animations too!
Project description
A python library and script for changing brightness on Linux via acpi. Allows for easing animations too!
pip install acpibacklight
You can use the script acpi-ease-backlight to adjust the backlight with easing via acpi on your device. See acpi-ease-backlight --help for options.
CLI Usage
After installing via pip, use the script acpi-ease-backlight. Here is how you might use it:
$ acpi-ease-backlight -h # see help
...
$ acpi-ease-backlight show # show the current backlight value
4000
$ acpi-ease-backlight max # show the your display's max backlight value
4882
$ acpi-ease-backlight set 2000 # set the backlight to 2000, over the default
# duration of 0.25 seconds and using the default
# easing function 'easeOutCubic'
$ acpi-ease-backlight -d 1 -e easeInOutQuad set 3000
# set the backlight to 3000 over duration of
# 1 second, using the easing function 'easeInOutQuad'
$ acpi-ease-backlight -d 0.5 dec 1000
# decrease the current backlight value by
# 1000 over a duration of 0.5 seconds
Library Usage
Use the class acpibacklight.AcpiBacklightControl for changing the backlight level in various ways. AcpiBacklightControl is designed to use python with statements similarly to file objects and python’s open builtin:
with AcpiBacklightControl() as ctrl:
# set the brightness without animating
ctrl.brightness = 2000
# get max brightness on this device
new_brightness = ctrl.max
# You can also use the animate function on the AcpiBacklightControl.
# See the docstring for kwargs
ctrl.animate(new_brightness, duration=0.75)
Alternatively, you can construct, then open, then close the AcpiBacklightControl:
ctrl = AcpiBacklightControl()
ctrl.open()
ctrl.animate(ctrl.brightness - 1000)
ctrl.close()
You can pass an easing function to be used in animate() by the easing_func keyword arg. This package uses PyTweening for its default animation and the CLI, so you can easily pass one of those:
import pytweening
ctrl.animate(2345, easing_func=pytweening.easeInOutBounce)
Finally, if you want to create and pass your own easing function, it should take one paramater (time) between 0 and 1, and return a value between 0 and 1. For instance, a linear easing function would look like:
def linear_easing(t):
# t is always in the range [0, 1]
return t
# ...
ctrl.animate(1234, easing_func=linear_easing)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file acpibacklight-0.1.3.tar.gz
.
File metadata
- Download URL: acpibacklight-0.1.3.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cda3637569aac8dbcd163325aae6156be4aefb9d7c99d716fc852005831edf6e |
|
MD5 | 09e63ab288ac5aa350cbfb8307006ee0 |
|
BLAKE2b-256 | 94624dbc25ebe628a9e081f420ac6e5e957a0cc7c4deecccf64411aabcb97e03 |
File details
Details for the file acpibacklight-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: acpibacklight-0.1.3-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffabfd3caf4f9a6c6885fcb13d69f389617c70bd4c9eadc3226d4ddc982a9497 |
|
MD5 | 367a34eea15fe0f35351b2686c3831a3 |
|
BLAKE2b-256 | 220a573792357984c0516036746dd2087867da36ef846dc355df821290b7246e |