用于通过acpi在Linux上更改亮度的库和脚本。还允许进行简化动画!
项目描述
一个用于通过acpi在Linux上更改亮度的Python库和脚本。还允许进行简化动画!
pip install acpibacklight
您可以使用脚本 acpi-ease-backlight 通过acpi在您的设备上调整背光,并使用简化效果。请查看 acpi-ease-backlight --help 以获取选项。
命令行使用
通过pip安装后,使用脚本 acpi-ease-backlight。以下是您可能使用它的方法
$ 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
库使用
实例化
使用类 acpibacklight.AcpiBacklightControl 以各种方式更改背光级别。AcpiBacklightControl 设计为类似于文件对象和Python的 open 内置函数使用Python with 语句
from acpibacklight import AcpiBacklightControl
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)
或者,您可以构建,然后打开,然后关闭 AcpiBacklightControl
ctrl = AcpiBacklightControl()
ctrl.open()
ctrl.animate(ctrl.brightness - 1000)
ctrl.close()
如果您有多个ACPI背光设备,请在构建 AcpiBacklightControl 时指定名称。否则,默认为找到的第一个设备目录。
ctrl = AcpiBacklightControl(device_dir='intel_backlight')
简化函数
您可以通过 easing_func 关键字参数将一个简化函数传递给 animate()。此包使用 PyTweening 作为其默认动画和命令行界面,因此您可以轻松传递其中的一个
import pytweening
ctrl.animate(2345, easing_func=pytweening.easeInOutBounce)
最后,如果您想创建并传递自己的简化函数,它应该接受一个介于0和1之间的一个参数(时间),并返回一个介于0和1之间的值。例如,一个线性简化函数看起来像
def linear_easing(t):
# t is always in the range [0, 1]
return t
# ...
ctrl.animate(1234, easing_func=linear_easing)
项目细节
关闭
acpibacklight-0.2.0.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | dc7b080f03dd29356d27f8b2240a7a6ca9cfff56e0c0294c8e50f993ac7e360a |
|
MD5 | 68d6da0f36acac3dad352104bdecb80b |
|
BLAKE2b-256 | 966bb61f70e9324a1e7a237eec5eeb0f56855afc01f102082c1a113bc48a64c7 |
关闭
acpibacklight-0.2.0-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 389f756b1db35c1e6d5d75b343e594b5fbba701da5485fa1067cff64ba0aa570 |
|
MD5 | d6d21d23b29bc49403de8ced957d97c4 |
|
BLAKE2b-256 | c30d407c9869af9b8783cb9d9d1f38dc7d11a227ba25ac3a49ac7877151ed4a1 |