From 1da03a79522a0f3423c9b32daa5493989ecd331b Mon Sep 17 00:00:00 2001 From: Hue Date: Sun, 21 Dec 2025 02:13:29 +0100 Subject: [PATCH 1/4] =?UTF-8?q?panel=C2=A0:=20add=20backlight=20control=20?= =?UTF-8?q?widget?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add backlight widget to control display brightness. Handles sysfs devices and external external monitors that implement MCCS. MCCS depends on libddcutil, and is not built if it is not detected. --- .github/workflows/ci.yaml | 2 +- meson.build | 6 + meson_options.txt | 6 + metadata/panel.xml | 33 ++ src/panel/meson.build | 9 + src/panel/panel.cpp | 13 +- src/panel/widgets/backlight/backlight.cpp | 269 ++++++++++++++ src/panel/widgets/backlight/backlight.hpp | 165 +++++++++ src/panel/widgets/backlight/ddcutil.cpp | 225 ++++++++++++ src/panel/widgets/backlight/sysfs.cpp | 404 ++++++++++++++++++++++ src/util/icon-select.hpp | 8 + 11 files changed, 1138 insertions(+), 2 deletions(-) create mode 100644 src/panel/widgets/backlight/backlight.cpp create mode 100644 src/panel/widgets/backlight/backlight.hpp create mode 100644 src/panel/widgets/backlight/ddcutil.cpp create mode 100644 src/panel/widgets/backlight/sysfs.cpp diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9d1f28a9..8efbedf8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,7 +9,7 @@ jobs: steps: - run: echo 'http://dl-cdn.alpinelinux.org/alpine/v3.22/community' > /etc/apk/repositories - run: echo 'http://dl-cdn.alpinelinux.org/alpine/v3.22/main' >> /etc/apk/repositories - - run: apk --no-cache add git g++ binutils pkgconf meson ninja musl-dev gtkmm4-dev vala gobject-introspection gobject-introspection-dev pulseaudio-dev pipewire-dev wireplumber-dev libdbusmenu-glib-dev alsa-lib-dev yyjson-dev linux-pam-dev util-linux-login openssl-dev + - run: apk --no-cache add git g++ binutils pkgconf meson ninja musl-dev gtkmm4-dev vala gobject-introspection gobject-introspection-dev ddcutil pulseaudio-dev pipewire-dev wireplumber-dev libdbusmenu-glib-dev alsa-lib-dev yyjson-dev linux-pam-dev util-linux-login openssl-dev - run: echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories - run: echo 'http://dl-cdn.alpinelinux.org/alpine/edge/main' >> /etc/apk/repositories - run: apk --no-cache add wayland-protocols wayfire-dev gtk4-layer-shell-dev gtk4-layer-shell diff --git a/meson.build b/meson.build index 36d56db6..9f5f4cf4 100644 --- a/meson.build +++ b/meson.build @@ -28,6 +28,8 @@ libpulse = dependency('libpulse', required: get_option('volume-widget')) libgvc = subproject('gvc', default_options: ['static=true'], required: get_option('volume-widget')) pipewire = dependency('libpipewire-0.3', required: get_option('wp-mixer-widget')) wireplumber = dependency('wireplumber-0.5', required: get_option('wp-mixer-widget')) +ddcutil = dependency('libddcutil-5', required: get_option('ddcutil')) +ddcutil = dependency('ddcutil', required: get_option('ddcutil')) dbusmenu_gtk = dependency('dbusmenu-glib-0.4') xkbregistry = dependency('xkbregistry') json = subproject('wf-json').get_variable('wfjson') @@ -57,6 +59,10 @@ if wireplumber.found() add_project_arguments('-DHAVE_WIREPLUMBER=1', language: 'cpp') endif +if ddcutil.found() + add_project_arguments('-DHAVE_DDCUTIL=1', language: 'cpp') +endif + needs_libinotify = ['freebsd', 'dragonfly'].contains(host_machine.system()) libinotify = dependency('libinotify', required: needs_libinotify) diff --git a/meson_options.txt b/meson_options.txt index 377f3cc3..73207a98 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -10,6 +10,12 @@ option( value: 'auto', description: 'Build wireplumber mixer widget', ) +option( + 'ddcutil', + type: 'feature', + value: 'auto', + description: 'Build external monitor support for backlight widget' +) option( 'wayland-logout', type: 'boolean', diff --git a/metadata/panel.xml b/metadata/panel.xml index cb53132d..1fc1baa8 100644 --- a/metadata/panel.xml +++ b/metadata/panel.xml @@ -395,6 +395,39 @@ + + <_short>Backlight + + + + + + + <_short>Notifications +