brightnessctl

repository·master·Indexed 21 days ago

https://github.com/hummer12007/brightnessctl

A Linux utility for reading and controlling device brightness, including backlights and LEDs. It supports percentage-based adjustments, delta changes, and state saving/restoring. The tool provides a CLI for operations such as getting, setting, and listing device brightness, with support for udev rules, SUID binaries, or systemd-logind for permission management.

Tokens
1.1K
Snippets
3
Records
6
Agent score
29%

What's inside brightnessctl

  1. Configure brightness for external monitors

    master
    By default, brightnessctl controls internal backlight and LEDs. To control the brightness of an external monitor, you must use the ddcci-driver-linux kernel module to expose those controls to the system. This module is available in the repositories for AUR, Debian, Nix, Ubuntu, and Void.
  2. Install brightnessctl

    master

    The brightnessctl program can be installed via package managers on various Linux distributions:

    • Alpine Linux: Available in edge.
    • Arch Linux: Available in extra/x86_64.
    • Void Linux: Available via void-packages.
    • Debian: Available starting with Buster (and derivatives).
    • Ubuntu: Available starting with 18.04 (and derivatives).
    • openSUSE: Available in Tumbleweed; use OBS utilities/brightnessctl for Leap < 15.1.
    • Fedora: Available in Fedora 31+.
    • NixOS/nix: Available starting with 17.09.

    Alternatively, you can build from source using:

    ./configure && make install

    Consult ./configure --help for build-time options.

  3. Use brightnessctl to control device brightness

    master

    The brightnessctl CLI follows this syntax: brightnessctl [options] [operation] [value]

    Operations

    • i, info: Get device information.
    • g, get: Get current brightness.
    • m, max: Get maximum brightness.
    • s, set VALUE: Set brightness to a specific value.

    Valid Values

    You can specify brightness using several formats:

    • Specific value: e.g., 500
    • Percentage value: e.g., 50%
    • Specific delta: e.g., 50- or +10
    • Percentage delta: e.g., 50%- or +10%

    Common Options

    • -l, --list: List devices with available brightness controls.
    • -d, --device=DEVICE: Specify a device name (supports wildcards).
    • -c, --class=CLASS: Specify a device class.
    • -s, --save: Save the current brightness state to a temporary file (useful for restoring later).
    • -r, --restore: Restore the previously saved state.
    • -q, --quiet: Suppress output.
    • -p, --pretend: Perform a dry run (do not write changes).
  4. Configure permissions for modifying brightness

    master

    Modifying brightness requires write permissions for device files or systemd support. brightnessctl supports three methods to achieve this without requiring sudo or su for every command:

    1. udev rules (Default): Installs rules that grant permissions to the video class for users in the video group, and the leds class for users in the input group. Ensure your user is a member of these groups.
    2. SUID binary: Installing brightnessctl as a suid binary.
    3. systemd-logind: Using the systemd-logind API.
  5. Reference: brightnessctl CLI options

    master

    Full list of command-line options for brightnessctl.

    Options:
      -l, --list           list devices with available brightness controls.
      -q, --quiet          suppress output.
      -p, --pretend        do not perform write operations.
      -m, --machine-readable produce machine-readable output.
      -n, --min-value      set minimum brightness, defaults to 1.
      -e, --exponent[=K]   changes percentage curve to exponential.
      -s, --save           save previous state in a temporary file.
      -r, --restore        restore previous saved state.
      -h, --help           print this help.
      -d, --device=DEVICE  specify device name (can be a wildcard).
      -c, --class=CLASS    specify device class.
      -V, --version        print version and exit.
  6. Reference: brightnessctl CLI operations

    master

    Full list of available operations for brightnessctl.

    Operations:
      i, info             get device info.
      g, get              get current brightness of the device.
      m, max              get maximum brightness of the device.
      s, set VALUE        set brightness of the device.