mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-28 02:31:25 +01:00
Brightness (Linux): removes ddcutil dep
This commit is contained in:
@@ -43,7 +43,7 @@ jobs:
|
||||
run: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
||||
|
||||
- name: install required packages
|
||||
run: sudo apt-get update && sudo apt-get install -y gcc-13 jq libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev ocl-icd-opencl-dev libdrm-dev libelf-dev libddcutil-dev libefl-all-dev libunwind-dev liblua5.4-dev libvdpau-dev libva-dev rpm ninja-build
|
||||
run: sudo apt-get update && sudo apt-get install -y gcc-13 jq libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev ocl-icd-opencl-dev libdrm-dev libelf-dev libefl-all-dev libunwind-dev liblua5.4-dev libvdpau-dev libva-dev rpm ninja-build
|
||||
|
||||
- name: install linuxbrew packages
|
||||
run: |
|
||||
|
||||
@@ -29,7 +29,7 @@ jobs:
|
||||
run: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
||||
|
||||
- name: install required packages
|
||||
run: sudo apt-get update && sudo apt-get install -y gcc-13 gcc-13-multilib libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev ocl-icd-opencl-dev libdrm-dev libelf-dev libddcutil-dev libefl-all-dev libunwind-dev liblua5.4-dev libvdpau-dev libva-dev rpm ninja-build
|
||||
run: sudo apt-get update && sudo apt-get install -y gcc-13 gcc-13-multilib libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libsqlite3-dev librpm-dev libegl-dev libglx-dev ocl-icd-opencl-dev libdrm-dev libelf-dev libefl-all-dev libunwind-dev liblua5.4-dev libvdpau-dev libva-dev rpm ninja-build
|
||||
|
||||
- name: install linuxbrew packages
|
||||
run: |
|
||||
|
||||
@@ -24,7 +24,7 @@ jobs:
|
||||
run: |
|
||||
cat /etc/alpine-release
|
||||
uname -a
|
||||
apk add cmake samurai vulkan-loader-dev libxcb-dev libxrandr-dev rpm-dev wayland-dev libdrm-dev dconf-dev imagemagick-dev chafa-dev zlib-dev dbus-dev mesa-dev opencl-dev sqlite-dev networkmanager-dev ddcutil-dev elfutils-dev lua5.4-dev quickjs-ng-dev libvdpau-dev libva-dev gcc g++
|
||||
apk add cmake samurai vulkan-loader-dev libxcb-dev libxrandr-dev rpm-dev wayland-dev libdrm-dev dconf-dev imagemagick-dev chafa-dev zlib-dev dbus-dev mesa-dev opencl-dev sqlite-dev networkmanager-dev elfutils-dev lua5.4-dev quickjs-ng-dev libvdpau-dev libva-dev gcc g++
|
||||
shell: alpine.sh --root {0}
|
||||
|
||||
- name: build
|
||||
|
||||
@@ -21,7 +21,7 @@ jobs:
|
||||
run: uname -a
|
||||
|
||||
- name: configure project
|
||||
run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr . -DENABLE_VULKAN=OFF -DENABLE_WAYLAND=OFF -DENABLE_XCB_RANDR=OFF -DENABLE_XCB=OFF -DENABLE_XRANDR=OFF -DENABLE_X11=OFF -DENABLE_DRM=OFF -DENABLE_DRM_AMDGPU=OFF -DENABLE_GIO=OFF -DENABLE_DCONF=OFF -DENABLE_DBUS=OFF -DENABLE_SQLITE3=OFF -DENABLE_RPM=OFF -DENABLE_IMAGEMAGICK7=OFF -DENABLE_IMAGEMAGICK6=OFF -DENABLE_CHAFA=OFF -DENABLE_ZLIB=OFF -DENABLE_EGL=OFF -DENABLE_GLX=OFF -DENABLE_OPENCL=OFF -DENABLE_FREETYPE=OFF -DENABLE_DDCUTIL=OFF -DENABLE_ELF=OFF -DENABLE_EET=OFF -DENABLE_THREADS=OFF -DENABLE_IMAGE_LOGO=OFF
|
||||
run: cmake -DSET_TWEAK=Off -DBUILD_TESTS=On -DCMAKE_INSTALL_PREFIX=/usr . -DENABLE_VULKAN=OFF -DENABLE_WAYLAND=OFF -DENABLE_XCB_RANDR=OFF -DENABLE_XCB=OFF -DENABLE_XRANDR=OFF -DENABLE_X11=OFF -DENABLE_DRM=OFF -DENABLE_DRM_AMDGPU=OFF -DENABLE_GIO=OFF -DENABLE_DCONF=OFF -DENABLE_DBUS=OFF -DENABLE_SQLITE3=OFF -DENABLE_RPM=OFF -DENABLE_IMAGEMAGICK7=OFF -DENABLE_IMAGEMAGICK6=OFF -DENABLE_CHAFA=OFF -DENABLE_ZLIB=OFF -DENABLE_EGL=OFF -DENABLE_GLX=OFF -DENABLE_OPENCL=OFF -DENABLE_FREETYPE=OFF -DENABLE_ELF=OFF -DENABLE_EET=OFF -DENABLE_THREADS=OFF -DENABLE_IMAGE_LOGO=OFF
|
||||
|
||||
- name: build project
|
||||
run: cmake --build . --target package --verbose -j4
|
||||
|
||||
@@ -92,7 +92,6 @@ cmake_dependent_option(ENABLE_EGL "Enable egl" ON "LINUX OR FreeBSD OR OpenBSD O
|
||||
cmake_dependent_option(ENABLE_GLX "Enable glx" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR ANDROID OR SunOS OR GNU" OFF)
|
||||
cmake_dependent_option(ENABLE_OPENCL "Enable opencl" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR WIN32 OR ANDROID OR SunOS OR Haiku OR GNU" OFF)
|
||||
cmake_dependent_option(ENABLE_FREETYPE "Enable freetype" ON "ANDROID" OFF)
|
||||
cmake_dependent_option(ENABLE_DDCUTIL "Enable ddcutil" ON "LINUX" OFF)
|
||||
cmake_dependent_option(ENABLE_ELF "Enable libelf" ON "LINUX OR ANDROID OR DragonFly OR Haiku OR GNU" OFF)
|
||||
cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND" OFF)
|
||||
|
||||
@@ -1846,10 +1845,6 @@ ff_lib_enable(FREETYPE
|
||||
"freetype2"
|
||||
"FreeType2"
|
||||
)
|
||||
ff_lib_enable(DDCUTIL
|
||||
"ddcutil"
|
||||
"Ddcutil"
|
||||
)
|
||||
ff_lib_enable(ELF
|
||||
"libelf"
|
||||
"libelf"
|
||||
|
||||
+1
-1
@@ -96,7 +96,7 @@ cmake -DBUILD_TESTS=On -DENABLE_VULKAN=OFF -DENABLE_WAYLAND=OFF -DENABLE_X11=OFF
|
||||
|
||||
Required: CMake ≥ 3.21 and a C23 compiler (GCC, Clang or MSVC). Everything else is optional.
|
||||
|
||||
Optional dependencies are auto-detected: libpci, libdrm, vulkan, wayland, xcb, xrandr, dbus, sqlite3, rpm, imagemagick{6,7}, chafa, zlib, egl, glx, opencl, freetype, ddcutil, elf, libzfs, and more.
|
||||
Optional dependencies are auto-detected: libpci, libdrm, vulkan, wayland, xcb, xrandr, dbus, sqlite3, rpm, imagemagick{6,7}, chafa, zlib, egl, glx, opencl, freetype, elf, libzfs, and more.
|
||||
|
||||
---
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@ Source: fastfetch
|
||||
Section: universe/utils
|
||||
Priority: optional
|
||||
Maintainer: Carter Li <zhangsongcui@live.cn>
|
||||
Build-Depends: libelf-dev, libvulkan-dev, libwayland-dev, libxrandr-dev, libxcb-randr0-dev, libdconf-dev, libdbus-1-dev, libmagickcore-dev, libsqlite3-dev, librpm-dev, libegl-dev, libglx-dev, ocl-icd-opencl-dev, libdrm-dev, libddcutil-dev, libchafa-dev, libefl-all-dev, pkgconf, cmake (>= 3.12), debhelper (>= 11.2), dh-cmake, dh-cmake-compat (= 1), dh-sequence-cmake, dh-sequence-ctest, ninja-build, python3-setuptools
|
||||
Build-Depends: libelf-dev, libvulkan-dev, libwayland-dev, libxrandr-dev, libxcb-randr0-dev, libdconf-dev, libdbus-1-dev, libmagickcore-dev, libsqlite3-dev, librpm-dev, libegl-dev, libglx-dev, ocl-icd-opencl-dev, libdrm-dev, libchafa-dev, libefl-all-dev, pkgconf, cmake (>= 3.12), debhelper (>= 11.2), dh-cmake, dh-cmake-compat (= 1), dh-sequence-cmake, dh-sequence-ctest, ninja-build, python3-setuptools
|
||||
Standards-Version: 4.0.0
|
||||
Homepage: https://github.com/fastfetch-cli/fastfetch
|
||||
|
||||
|
||||
@@ -1914,7 +1914,7 @@
|
||||
"$ref": "#/$defs/percent"
|
||||
},
|
||||
"ddcciSleep": {
|
||||
"description": "Sleep time in milliseconds between DDC/CI requests\nSet to null to skip DDC/CI detection\nSee <https://www.ddcutil.com/performance_options/#option-sleep-multiplier> for details",
|
||||
"description": "Sleep time in milliseconds between DDC/CI requests\nSet to null to skip DDC/CI detection",
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "null",
|
||||
|
||||
@@ -248,9 +248,6 @@ void ffListFeatures(void) {
|
||||
#if FF_HAVE_FREETYPE
|
||||
"freetype\n"
|
||||
#endif
|
||||
#if FF_HAVE_DDCUTIL
|
||||
"libddcutil\n"
|
||||
#endif
|
||||
#if FF_HAVE_ELF || __sun || (__FreeBSD__ && !__DragonFly__) || __OpenBSD__ || __NetBSD__
|
||||
"libelf\n"
|
||||
#endif
|
||||
|
||||
@@ -252,14 +252,9 @@
|
||||
return result->length > resultLength;
|
||||
}
|
||||
|
||||
static const char* detectWithDdcciNative(FFBrightnessOptions* options, FFlist* result, uint32_t expectedResultLength) {
|
||||
#ifdef FF_HAVE_DDCUTIL
|
||||
const uint32_t resultLength = result->length;
|
||||
#else
|
||||
(void) expectedResultLength;
|
||||
#endif
|
||||
static const char* detectWithDdcciNative(FFBrightnessOptions* options, FFlist* result) {
|
||||
FFBrightnessDdcCache cache = {0};
|
||||
FF_DEBUG("Brightness DDC/CI: native detection started (result count=%u, expected=%u)", result->length, expectedResultLength);
|
||||
FF_DEBUG("Brightness DDC/CI: native detection started (result count=%u)", result->length);
|
||||
if (!loadCacheFromFile(&cache)) {
|
||||
if (!scanI2cDevices(options, &cache)) {
|
||||
FF_DEBUG("Brightness DDC/CI: no compatible I2C device found during initial scan");
|
||||
@@ -277,17 +272,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FF_HAVE_DDCUTIL
|
||||
if (result->length < expectedResultLength) {
|
||||
FF_DEBUG("Brightness DDC/CI: native result is incomplete (%u/%u); rolling back for ddcutil fallback", result->length, expectedResultLength);
|
||||
FFBrightnessResult discarded;
|
||||
while (result->length > resultLength && FF_LIST_POP(*result, &discarded)) {
|
||||
ffStrbufDestroy(&discarded.name);
|
||||
}
|
||||
return "Native DDC/CI found only a subset of displays";
|
||||
}
|
||||
#endif
|
||||
|
||||
saveCacheToFile(&cache);
|
||||
FF_DEBUG("Brightness DDC/CI: native detection finished with %u result(s)", result->length);
|
||||
return nullptr;
|
||||
@@ -365,91 +349,6 @@ static const char* detectWithBacklight(FFlist* result) {
|
||||
|
||||
#include "detection/displayserver/displayserver.h"
|
||||
|
||||
#ifdef FF_HAVE_DDCUTIL
|
||||
#include "common/library.h"
|
||||
#include "common/mallocHelper.h"
|
||||
|
||||
#include <ddcutil_macros.h>
|
||||
#include <ddcutil_c_api.h>
|
||||
|
||||
// Try to be compatible with ddcutil 2.0
|
||||
#if DDCUTIL_VMAJOR >= 2
|
||||
double ddca_set_default_sleep_multiplier(double multiplier); // ddcutil 1.4
|
||||
#else
|
||||
DDCA_Status ddca_init(const char* libopts, int syslog_level, int opts);
|
||||
#endif
|
||||
|
||||
static const char* detectWithDdcci([[maybe_unused]] FFBrightnessOptions* options, FFlist* result) {
|
||||
FF_LIBRARY_LOAD_MESSAGE(libddcutil, "libddcutil" FF_LIBRARY_EXTENSION, 5);
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_get_display_info_list2)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_open_display2)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_get_any_vcp_value_using_explicit_type)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_free_any_vcp_value)
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_close_display)
|
||||
|
||||
// libddcutil may print trace messages to stdout during display detection, not only in ddca_init
|
||||
FF_SUPPRESS_IO();
|
||||
|
||||
#ifndef FF_DISABLE_DLOPEN
|
||||
FF_LIBRARY_LOAD_SYMBOL_LAZY(libddcutil, ddca_init)
|
||||
if (ffddca_init) {
|
||||
// Ref: https://github.com/rockowitz/ddcutil/issues/344
|
||||
if (ffddca_init(nullptr, -1 /*DDCA_SYSLOG_NOT_SET*/, 1 /*DDCA_INIT_OPTIONS_DISABLE_CONFIG_FILE*/) < 0) {
|
||||
return "ddca_init() failed";
|
||||
}
|
||||
} else {
|
||||
FF_LIBRARY_LOAD_SYMBOL_LAZY(libddcutil, ddca_set_default_sleep_multiplier);
|
||||
if (ffddca_set_default_sleep_multiplier) {
|
||||
ffddca_set_default_sleep_multiplier(options->ddcciSleep / 40.0);
|
||||
}
|
||||
|
||||
libddcutil = nullptr; // Don't dlclose libddcutil. See https://github.com/rockowitz/ddcutil/issues/330
|
||||
}
|
||||
#else
|
||||
#if DDCUTIL_VMAJOR >= 2
|
||||
if (ddca_init(nullptr, -1 /*DDCA_SYSLOG_NOT_SET*/, 1 /*DDCA_INIT_OPTIONS_DISABLE_CONFIG_FILE*/) < 0) {
|
||||
return "ddca_init() failed";
|
||||
}
|
||||
#else
|
||||
ddca_set_default_sleep_multiplier(options->ddcciSleep / 40.0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
FF_AUTO_FREE DDCA_Display_Info_List* infoList = nullptr;
|
||||
if (ffddca_get_display_info_list2(false, &infoList) < 0) {
|
||||
return "ddca_get_display_info_list2(false, &infoList) failed";
|
||||
}
|
||||
|
||||
if (infoList->ct == 0) {
|
||||
return "No DDC/CI compatible displays found";
|
||||
}
|
||||
|
||||
for (int index = 0; index < infoList->ct; ++index) {
|
||||
const DDCA_Display_Info* display = &infoList->info[index];
|
||||
|
||||
DDCA_Display_Handle handle;
|
||||
if (ffddca_open_display2(display->dref, false, &handle) >= 0) {
|
||||
DDCA_Any_Vcp_Value* vcpValue = nullptr;
|
||||
if (ffddca_get_any_vcp_value_using_explicit_type(handle, 0x10 /*brightness*/, DDCA_NON_TABLE_VCP_VALUE, &vcpValue) >= 0) {
|
||||
assert(vcpValue->value_type == DDCA_NON_TABLE_VCP_VALUE);
|
||||
int current = VALREC_CUR_VAL(vcpValue), max = VALREC_MAX_VAL(vcpValue);
|
||||
ffddca_free_any_vcp_value(vcpValue);
|
||||
|
||||
FFBrightnessResult* brightness = FF_LIST_ADD(FFBrightnessResult, *result);
|
||||
brightness->max = max;
|
||||
brightness->min = 0;
|
||||
brightness->current = current;
|
||||
brightness->builtin = false;
|
||||
ffStrbufInitS(&brightness->name, display->model_name);
|
||||
}
|
||||
ffddca_close_display(handle);
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
const char* ffDetectBrightness([[maybe_unused]] FFBrightnessOptions* options, FFlist* result) {
|
||||
FF_DEBUG("Brightness: detection started (result count=%u)", result->length);
|
||||
detectWithBacklight(result);
|
||||
@@ -460,18 +359,10 @@ const char* ffDetectBrightness([[maybe_unused]] FFBrightnessOptions* options, FF
|
||||
if (result->length < displayServer->displays.length) {
|
||||
FF_DEBUG("Brightness: trying native DDC/CI (result count=%u, display count=%u)", result->length, displayServer->displays.length);
|
||||
#if defined(__linux__)
|
||||
// Try native I2C first
|
||||
const char* nativeError = detectWithDdcciNative(options, result, displayServer->displays.length);
|
||||
const char* nativeError = detectWithDdcciNative(options, result);
|
||||
if (nativeError != nullptr) {
|
||||
#ifdef FF_HAVE_DDCUTIL
|
||||
FF_DEBUG("Native I2C DDC/CI failed: %s, falling back to ddcutil", nativeError);
|
||||
detectWithDdcci(options, result);
|
||||
#else
|
||||
FF_DEBUG("Native I2C DDC/CI failed: %s; ddcutil fallback is unavailable", nativeError);
|
||||
#endif
|
||||
FF_DEBUG("Native I2C DDC/CI failed: %s", nativeError);
|
||||
}
|
||||
#elif defined(FF_HAVE_DDCUTIL)
|
||||
detectWithDdcci(options, result);
|
||||
#endif
|
||||
} else {
|
||||
FF_DEBUG("Brightness: skipping DDC/CI because result count=%u meets display count=%u", result->length, displayServer->displays.length);
|
||||
|
||||
Reference in New Issue
Block a user