跳转到主要内容

用于通过acpi在Linux上更改亮度的库和脚本。还允许进行简化动画!

项目描述

PyPI version

一个用于通过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 (4.7 kB 查看哈希值)

上传时间 源代码

构建发行版

acpibacklight-0.2.0-py3-none-any.whl (7.5 kB 查看哈希值)

上传时间 Python 3

由以下组织支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面