From 105cfe2a6252b06308067037c877c7422d822e17 Mon Sep 17 00:00:00 2001
From: Gleb Popov <6yearold@gmail.com>
Date: Thu, 16 Nov 2023 15:16:31 +0000
Subject: [PATCH] backlighthelper: Implement support for the FreeBSD
 backlight(8) interface

---
 daemon/backends/upower/CMakeLists.txt         |   9 +-
 .../upower/freebsdbacklighthelper.cpp         | 289 ++++++++++++++++++
 .../backends/upower/freebsdbacklighthelper.h  |  70 +++++
 ...ghthelper.cpp => linuxbacklighthelper.cpp} | 129 +-------
 ...cklighthelper.h => linuxbacklighthelper.h} |   5 -
 5 files changed, 377 insertions(+), 125 deletions(-)
 create mode 100644 daemon/backends/upower/freebsdbacklighthelper.cpp
 create mode 100644 daemon/backends/upower/freebsdbacklighthelper.h
 rename daemon/backends/upower/{backlighthelper.cpp => linuxbacklighthelper.cpp} (66%)
 rename daemon/backends/upower/{backlighthelper.h => linuxbacklighthelper.h} (94%)

diff --git a/daemon/backends/upower/CMakeLists.txt b/daemon/backends/upower/CMakeLists.txt
index d98e13ef8..6526db037 100644
--- a/daemon/backends/upower/CMakeLists.txt
+++ b/daemon/backends/upower/CMakeLists.txt
@@ -29,7 +29,14 @@ qt_add_dbus_interface(powerdevilupowerbackend_SRCS
 )
 
 ## backlight helper executable
-add_executable(backlighthelper backlighthelper.cpp ${CMAKE_BINARY_DIR}/daemon/powerdevil_debug.cpp)
+set(backlighthelpers_SRCS ${CMAKE_BINARY_DIR}/daemon/powerdevil_debug.cpp)
+if (CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
+    list(APPEND backlighthelpers_SRCS freebsdbacklighthelper.cpp)
+else()
+    list(APPEND backlighthelpers_SRCS linuxbacklighthelper.cpp)
+endif()
+
+add_executable(backlighthelper ${backlighthelpers_SRCS})
 target_link_libraries(backlighthelper Qt::Core KF5::AuthCore KF5::I18n)
 install(TARGETS backlighthelper DESTINATION ${KAUTH_HELPER_INSTALL_DIR})
 kauth_install_helper_files(backlighthelper org.kde.powerdevil.backlighthelper root)
diff --git a/daemon/backends/upower/freebsdbacklighthelper.cpp b/daemon/backends/upower/freebsdbacklighthelper.cpp
new file mode 100644
index 000000000..23093f579
--- /dev/null
+++ b/daemon/backends/upower/freebsdbacklighthelper.cpp
@@ -0,0 +1,289 @@
+/*  This file is part of the KDE project
+ *    Copyright (C) 2012 Alberto Villa <avilla@FreeBSD.org>
+ *    Copyright (C) 2023 Serenity Cyber Security, LLC <license@futurecrew.ru>
+ *                       Author: Gleb Popov <arrowd@FreeBSD.org>
+ *
+ *    This library is free software; you can redistribute it and/or
+ *    modify it under the terms of the GNU Library General Public
+ *    License version 2 as published by the Free Software Foundation.
+ *
+ *    This library is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *    Library General Public License for more details.
+ *
+ *    You should have received a copy of the GNU Library General Public License
+ *    along with this library; see the file COPYING.LIB.  If not, write to
+ *    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *    Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "freebsdbacklighthelper.h"
+
+#include <powerdevil_debug.h>
+
+#include <QDebug>
+#include <QDir>
+#include <QProcess>
+
+#include <KLocalizedString>
+
+#include <algorithm>
+#include <climits>
+#include <sys/sysctl.h>
+#include <sys/types.h>
+#include <sys/utsname.h>
+
+#define BACKLIGHT_PATH "/dev/backlight/"
+// man backlight states that the brightness value is always between 0 and 100
+#define BACKLIGHT_MAX_BRIGHTNESS 100
+#define HAS_SYSCTL(n) (sysctlbyname(n, nullptr, nullptr, nullptr, 0) == 0)
+
+static QByteArray runFreeBSDBacklight(const QStringList &args)
+{
+    QProcess backlight;
+    backlight.setProgram(QStringLiteral("backlight"));
+    backlight.setArguments(args);
+    backlight.start(QIODevice::ReadOnly);
+    backlight.waitForFinished();
+    return backlight.readAllStandardOutput();
+}
+
+BacklightHelper::BacklightHelper(QObject *parent)
+    : QObject(parent)
+{
+    initUsingFreeBSDBacklight();
+
+    if (m_devices.isEmpty()) {
+        initUsingSysctl();
+
+        if (m_sysctlDevice.isEmpty() || m_sysctlBrightnessLevels.isEmpty()) {
+            qCWarning(POWERDEVIL) << "no kernel backlight interface found";
+            return;
+        }
+    }
+
+    m_anim.setEasingCurve(QEasingCurve::InOutQuad);
+    connect(&m_anim, &QVariantAnimation::valueChanged, this, [this](const QVariant &value) {
+        // When animating to zero, it emits a value change to 0 before starting the animation...
+        if (m_anim.state() == QAbstractAnimation::Running) {
+            writeBrightness(value.toInt());
+        }
+    });
+
+    m_isSupported = true;
+}
+
+int BacklightHelper::readFromDevice(const QString &device) const
+{
+    bool ok;
+    int value = runFreeBSDBacklight({QStringLiteral("-qf"), device}).toInt(&ok);
+    return ok ? value : -1;
+}
+
+bool BacklightHelper::writeToDevice(const QString &device, int brightness) const
+{
+    return 0 == QProcess::execute(QStringLiteral("backlight"), {QStringLiteral("-f"), device, QString::number(brightness)});
+}
+
+void BacklightHelper::initUsingSysctl()
+{
+    /*
+     * lcd0 is, in theory, the correct device, but some vendors have custom ACPI implementations
+     * which cannot be interpreted. In that case, devices should be reported as "out", but
+     * FreeBSD doesn't care (yet), so they can appear as any other type. Let's search for the first
+     * device with brightness management, then.
+     */
+    /*
+     * The acpi_video interface is not standartized and will not work for some vendors due to
+     * the sysctl being named hw.acpi.video_<vendor>.*
+     */
+    QStringList types;
+    types << QStringLiteral("lcd") << QStringLiteral("out") << QStringLiteral("crt") << QStringLiteral("tv") << QStringLiteral("ext");
+    for (const QString &type : types) {
+        for (int i = 0; m_sysctlDevice.isEmpty(); i++) {
+            QString device = QStringLiteral("%1%2").arg(type, QString::number(i));
+            // We don't care about the value, we only want the sysctl to be there.
+            if (!HAS_SYSCTL(qPrintable(QStringLiteral("hw.acpi.video.%1.active").arg(device)))) {
+                break;
+            }
+            if (HAS_SYSCTL(qPrintable(QStringLiteral("hw.acpi.video.%1.brightness").arg(device)))
+                && HAS_SYSCTL(qPrintable(QStringLiteral("hw.acpi.video.%1.levels").arg(device)))) {
+                m_sysctlDevice = device;
+                break;
+            }
+        }
+    }
+
+    if (m_sysctlDevice.isEmpty()) {
+        return;
+    }
+
+    size_t len;
+    if (sysctlbyname(qPrintable(QStringLiteral("hw.acpi.video.%1.levels").arg(m_sysctlDevice)), nullptr, &len, nullptr, 0) != 0 || len == 0) {
+        return;
+    }
+    int *levels = (int *)malloc(len);
+    if (!levels) {
+        return;
+    }
+    if (sysctlbyname(qPrintable(QString("hw.acpi.video.%1.levels").arg(m_sysctlDevice)), levels, &len, nullptr, 0) != 0) {
+        free(levels);
+        return;
+    }
+    // acpi_video(4) supports only some predefined brightness levels.
+    int nlevels = len / sizeof(int);
+    for (int i = 0; i < nlevels; i++) {
+        m_sysctlBrightnessLevels << levels[i];
+    }
+    free(levels);
+    // Sorting helps when finding max value and when scanning for the nearest level in setbrightness().
+    std::sort(m_sysctlBrightnessLevels.begin(), m_sysctlBrightnessLevels.end());
+}
+
+void BacklightHelper::initUsingFreeBSDBacklight()
+{
+    QDir ledsDir(QStringLiteral(BACKLIGHT_PATH));
+    ledsDir.setFilter(QDir::NoDotAndDotDot | QDir::System);
+    ledsDir.setNameFilters({QStringLiteral("backlight*")});
+
+    QStringList devices = ledsDir.entryList();
+
+    for (auto &devName : devices) {
+        auto devPath = QStringLiteral(BACKLIGHT_PATH) + devName;
+        auto output = runFreeBSDBacklight({QStringLiteral("-if"), devPath});
+        // % backlight -if /dev/backlight/backlight0
+        // Backlight name: intel_backlight
+        // Backlight hardware type: Panel
+        if (output.contains(": Panel")) {
+            m_devices.append(qMakePair(devPath, 100));
+        }
+    }
+}
+
+ActionReply BacklightHelper::brightness(const QVariantMap &args)
+{
+    Q_UNUSED(args);
+    const int brightness = readBrightness();
+
+    if (brightness == -1) {
+        return ActionReply::HelperErrorReply();
+    }
+
+    ActionReply reply;
+    reply.addData(QStringLiteral("brightness"), brightness);
+    return reply;
+}
+
+int BacklightHelper::readBrightness() const
+{
+    if (!m_isSupported) {
+        return -1;
+    }
+
+    int brightness = -1;
+
+    if (!m_sysctlDevice.isEmpty()) {
+        size_t len = sizeof(int);
+        if (sysctlbyname(qPrintable(QStringLiteral("hw.acpi.video.%1.brightness").arg(m_sysctlDevice)), &brightness, &len, nullptr, 0) != 0) {
+            return -1;
+        }
+    } else {
+        brightness = readFromDevice(m_devices.constFirst().first);
+    }
+
+    return brightness;
+}
+
+ActionReply BacklightHelper::setbrightness(const QVariantMap &args)
+{
+    if (!m_isSupported) {
+        return ActionReply::HelperErrorReply();
+    }
+
+    const int brightness = args.value(QStringLiteral("brightness")).toInt();
+    const int animationDuration = args.value(QStringLiteral("animationDuration")).toInt();
+
+    m_anim.stop();
+
+    if (animationDuration <= 0) {
+        writeBrightness(brightness);
+        return ActionReply::SuccessReply();
+    }
+
+    m_anim.setDuration(animationDuration);
+    m_anim.setStartValue(readBrightness());
+    m_anim.setEndValue(brightness);
+    m_anim.start();
+
+    return ActionReply::SuccessReply();
+}
+
+bool BacklightHelper::writeBrightness(int brightness) const
+{
+    if (!m_sysctlDevice.isEmpty()) {
+        int actual_level = -1;
+        int d1 = 101;
+        // Search for the nearest level.
+        for (int level : m_sysctlBrightnessLevels) {
+            int d2 = qAbs(level - brightness);
+            /*
+             * The list is sorted, so we break when it starts diverging. There may be repeated values,
+             * so we keep going on equal gap (e.g., value = 7.5, levels = 0 0 10 ...: we don't break at
+             * the second '0' so we can get to the '10'). This also means that the value will always
+             * round off to the bigger level when in the middle (e.g., value = 5, levels = 0 10 ...:
+             * value rounds off to 10).
+             */
+            if (d2 > d1) {
+                break;
+            }
+            actual_level = level;
+            d1 = d2;
+        }
+        size_t len = sizeof(int);
+        return sysctlbyname(qPrintable(QStringLiteral("hw.acpi.video.%1.brightness").arg(m_sysctlDevice)), nullptr, nullptr, &actual_level, len) == 0;
+    }
+
+    if (!m_devices.isEmpty()) {
+        const int first_maxbrightness = std::max(1, m_devices.constFirst().second);
+        for (const auto &device : m_devices) {
+            // Some monitor brightness values are ridiculously high, and can easily overflow during computation
+            const qint64 new_brightness_64 = static_cast<qint64>(brightness) * static_cast<qint64>(device.second) / static_cast<qint64>(first_maxbrightness);
+            // cautiously truncate it back
+            const int new_brightness = static_cast<int>(std::min(static_cast<qint64>(std::numeric_limits<int>::max()), new_brightness_64));
+            writeToDevice(device.first, new_brightness);
+        }
+    }
+
+    return true;
+}
+
+ActionReply BacklightHelper::syspath(const QVariantMap &args)
+{
+    Q_UNUSED(args);
+    return ActionReply::HelperErrorReply();
+}
+
+ActionReply BacklightHelper::brightnessmax(const QVariantMap &args)
+{
+    Q_UNUSED(args);
+
+    if (!m_isSupported) {
+        return ActionReply::HelperErrorReply();
+    }
+
+    int max_brightness = !m_sysctlBrightnessLevels.isEmpty() ? m_sysctlBrightnessLevels.last() : BACKLIGHT_MAX_BRIGHTNESS;
+
+    if (max_brightness <= 0) {
+        return ActionReply::HelperErrorReply();
+    }
+
+    ActionReply reply;
+    reply.addData(QStringLiteral("brightnessmax"), max_brightness);
+    // qCDebug(POWERDEVIL) << "data contains:" << reply.data()["brightnessmax"];
+
+    return reply;
+}
+
+KAUTH_HELPER_MAIN("org.kde.powerdevil.backlighthelper", BacklightHelper)
diff --git a/daemon/backends/upower/freebsdbacklighthelper.h b/daemon/backends/upower/freebsdbacklighthelper.h
new file mode 100644
index 000000000..ab9b0e20a
--- /dev/null
+++ b/daemon/backends/upower/freebsdbacklighthelper.h
@@ -0,0 +1,70 @@
+/*  This file is part of the KDE project
+ *    Copyright (C) 2012 Alberto Villa <avilla@FreeBSD.org>
+ *    Copyright (C) 2023 Serenity Cyber Security, LLC <license@futurecrew.ru>
+ *                       Author: Gleb Popov <arrowd@FreeBSD.org>
+ *
+ *    This library is free software; you can redistribute it and/or
+ *    modify it under the terms of the GNU Library General Public
+ *    License version 2 as published by the Free Software Foundation.
+ *
+ *    This library is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *    Library General Public License for more details.
+ *
+ *    You should have received a copy of the GNU Library General Public License
+ *    along with this library; see the file COPYING.LIB.  If not, write to
+ *    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *    Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef BACKLIGHTHELPER_H
+#define BACKLIGHTHELPER_H
+
+#include <QObject>
+#include <QVariantAnimation>
+
+#include <KAuth/ActionReply>
+#include <KAuth/HelperSupport>
+#include <kauth_version.h>
+
+using namespace KAuth;
+
+class BacklightHelper : public QObject
+{
+    Q_OBJECT
+public:
+    explicit BacklightHelper(QObject *parent = nullptr);
+
+public Q_SLOTS:
+    ActionReply brightness(const QVariantMap &args);
+    ActionReply brightnessmax(const QVariantMap &args);
+    ActionReply setbrightness(const QVariantMap &args);
+    ActionReply syspath(const QVariantMap &args);
+
+private:
+    int readBrightness() const;
+    bool writeBrightness(int brightness) const;
+
+    int readFromDevice(const QString &device) const;
+    bool writeToDevice(const QString &device, int brightness) const;
+
+    /**
+     * FreeBSD (and other BSDs) can control backlight via acpi_video(4)
+     */
+    void initUsingSysctl();
+    /**
+     * FreeBSD 13+ has a dedicated command line utility backlight(8)
+     */
+    void initUsingFreeBSDBacklight();
+
+    bool m_isSupported = false;
+    QString m_sysctlDevice;
+    QList<int> m_sysctlBrightnessLevels;
+    QList<QPair<QString /*device path*/, int /*max brightness*/>> m_devices;
+
+    QVariantAnimation m_anim;
+};
+
+#endif // BACKLIGHTHELPER_H
diff --git a/daemon/backends/upower/backlighthelper.cpp b/daemon/backends/upower/linuxbacklighthelper.cpp
similarity index 66%
rename from daemon/backends/upower/backlighthelper.cpp
rename to daemon/backends/upower/linuxbacklighthelper.cpp
index 04a6edd00..7ab89c820 100644
--- a/daemon/backends/upower/backlighthelper.cpp
+++ b/daemon/backends/upower/linuxbacklighthelper.cpp
@@ -17,11 +17,12 @@
  *
  */
 
-#include "backlighthelper.h"
+#include "linuxbacklighthelper.h"
 
 #include <powerdevil_debug.h>
 
 #include <QDir>
+#include <QProcess>
 #include <QDebug>
 
 #include <KLocalizedString>
@@ -30,17 +31,6 @@
 #include <climits>
 #include <sys/utsname.h>
 
-#ifdef Q_OS_FREEBSD
-#define USE_SYSCTL
-#endif
-
-#ifdef USE_SYSCTL
-#include <sys/types.h>
-#include <sys/sysctl.h>
-
-#define HAS_SYSCTL(n) (sysctlbyname(n, nullptr, nullptr, nullptr, 0) == 0)
-#endif
-
 #define BACKLIGHT_SYSFS_PATH "/sys/class/backlight/"
 #define LED_SYSFS_PATH "/sys/class/leds/"
 
@@ -54,12 +44,8 @@ void BacklightHelper::init()
     initUsingBacklightType();
 
     if (m_devices.isEmpty()) {
-        initUsingSysctl();
-
-        if (m_sysctlDevice.isEmpty() || m_sysctlBrightnessLevels.isEmpty()) {
-            qCWarning(POWERDEVIL) << "no kernel backlight interface found";
-            return;
-        }
+        qCWarning(POWERDEVIL) << "no kernel backlight interface found";
+        return;
     }
 
     m_anim.setEasingCurve(QEasingCurve::InOutQuad);
@@ -75,16 +61,18 @@ void BacklightHelper::init()
 
 int BacklightHelper::readFromDevice(const QString &device, const QString &property) const
 {
-    int value;
+    int value = -1;
+
     QFile file(device + "/" + property);
     if (!file.open(QIODevice::ReadOnly)) {
         qCWarning(POWERDEVIL) << "reading from device " << device << "/" << property << " failed with error code " << file.error() << file.errorString();
-        return -1;
+        return value;
     }
 
     QTextStream stream(&file);
     stream >> value;
     file.close();
+
     return value;
 }
 
@@ -185,60 +173,6 @@ void BacklightHelper::initUsingBacklightType()
     return;
 }
 
-void BacklightHelper::initUsingSysctl()
-{
-#ifdef USE_SYSCTL
-    /*
-     * lcd0 is, in theory, the correct device, but some vendors have custom ACPI implementations
-     * which cannot be interpreted. In that case, devices should be reported as "out", but
-     * FreeBSD doesn't care (yet), so they can appear as any other type. Let's search for the first
-     * device with brightness management, then.
-     */
-    QStringList types;
-    types << QStringLiteral("lcd") << QStringLiteral("out") << QStringLiteral("crt") << QStringLiteral("tv") << QStringLiteral("ext");
-    for (const QString &type : types) {
-        for (int i = 0; m_sysctlDevice.isEmpty(); i++) {
-            QString device = QStringLiteral("%1%2").arg(type, QString::number(i));
-            // We don't care about the value, we only want the sysctl to be there.
-            if (!HAS_SYSCTL(qPrintable(QStringLiteral("hw.acpi.video.%1.active").arg(device)))) {
-                break;
-            }
-            if (HAS_SYSCTL(qPrintable(QStringLiteral("hw.acpi.video.%1.brightness").arg(device))) &&
-                HAS_SYSCTL(qPrintable(QStringLiteral("hw.acpi.video.%1.levels").arg(device)))) {
-                m_sysctlDevice = device;
-                break;
-            }
-        }
-    }
-
-    if (m_sysctlDevice.isEmpty()) {
-        return;
-    }
-
-    size_t len;
-    if (sysctlbyname(qPrintable(QStringLiteral("hw.acpi.video.%1.levels").arg(m_sysctlDevice)), nullptr, &len, nullptr, 0) != 0 ||
-        len == 0) {
-        return;
-    }
-    int *levels = (int *)malloc(len);
-    if (!levels) {
-        return;
-    }
-    if (sysctlbyname(qPrintable(QString("hw.acpi.video.%1.levels").arg(m_sysctlDevice)), levels, &len, nullptr, 0) != 0) {
-        free(levels);
-        return;
-    }
-    // acpi_video(4) supports only some predefined brightness levels.
-    int nlevels = len / sizeof(int);
-    for (int i = 0; i < nlevels; i++) {
-        m_sysctlBrightnessLevels << levels[i];
-    }
-    free(levels);
-    // Sorting helps when finding max value and when scanning for the nearest level in setbrightness().
-    std::sort(m_sysctlBrightnessLevels.begin(), m_sysctlBrightnessLevels.end());
-#endif
-}
-
 ActionReply BacklightHelper::brightness(const QVariantMap &args)
 {
     Q_UNUSED(args);
@@ -259,18 +193,7 @@ int BacklightHelper::readBrightness() const
         return -1;
     }
 
-    int brightness;
-
-#ifdef USE_SYSCTL
-    size_t len = sizeof(int);
-    if (sysctlbyname(qPrintable(QStringLiteral("hw.acpi.video.%1.brightness").arg(m_sysctlDevice)), &brightness, &len, nullptr, 0) != 0) {
-        return -1;
-    }
-#else
-    brightness = readFromDevice(m_devices.constFirst().first, QLatin1String("brightness"));
-#endif
-
-    return brightness;
+    return readFromDevice(m_devices.constFirst().first, QLatin1String("brightness"));
 }
 
 ActionReply BacklightHelper::setbrightness(const QVariantMap &args)
@@ -299,29 +222,6 @@ ActionReply BacklightHelper::setbrightness(const QVariantMap &args)
 
 bool BacklightHelper::writeBrightness(int brightness) const
 {
-#ifdef USE_SYSCTL
-    int actual_level = -1;
-    int d1 = 101;
-    // Search for the nearest level.
-    for (int level : m_sysctlBrightnessLevels) {
-        int d2 = qAbs(level - brightness);
-        /*
-         * The list is sorted, so we break when it starts diverging. There may be repeated values,
-         * so we keep going on equal gap (e.g., value = 7.5, levels = 0 0 10 ...: we don't break at
-         * the second '0' so we can get to the '10'). This also means that the value will always
-         * round off to the bigger level when in the middle (e.g., value = 5, levels = 0 10 ...:
-         * value rounds off to 10).
-         */
-        if (d2 > d1) {
-            break;
-        }
-        actual_level = level;
-        d1 = d2;
-    }
-    size_t len = sizeof(int);
-    return sysctlbyname(qPrintable(QStringLiteral("hw.acpi.video.%1.brightness").arg(m_sysctlDevice)), nullptr, nullptr, &actual_level, len) == 0;
-#else
-
     if (!m_devices.isEmpty()) {
         const int first_maxbrightness = std::max(1, m_devices.constFirst().second);
         for (const auto &device : m_devices) {
@@ -334,9 +234,6 @@ bool BacklightHelper::writeBrightness(int brightness) const
     }
 
     return true;
-#endif
-
-    return false;
 }
 
 ActionReply BacklightHelper::syspath(const QVariantMap &args)
@@ -367,13 +264,7 @@ ActionReply BacklightHelper::brightnessmax(const QVariantMap &args)
     }
 
     // maximum brightness
-    int max_brightness;
-
-#ifdef USE_SYSCTL
-    max_brightness = m_sysctlBrightnessLevels.last();
-#else
-    max_brightness = readFromDevice(m_devices.constFirst().first, QLatin1String("max_brightness"));
-#endif
+    int max_brightness = readFromDevice(m_devices.constFirst().first, QLatin1String("max_brightness"));
 
     if (max_brightness <= 0) {
         reply = ActionReply::HelperErrorReply();
diff --git a/daemon/backends/upower/backlighthelper.h b/daemon/backends/upower/linuxbacklighthelper.h
similarity index 94%
rename from daemon/backends/upower/backlighthelper.h
rename to daemon/backends/upower/linuxbacklighthelper.h
index 87b15e68e..10ca05222 100644
--- a/daemon/backends/upower/backlighthelper.h
+++ b/daemon/backends/upower/linuxbacklighthelper.h
@@ -58,11 +58,6 @@ private:
     void initUsingBacklightType();
     QStringList getBacklightTypeDevices() const;
 
-    /**
-     * FreeBSD (and other BSDs) can control backlight via acpi_video(4)
-     */
-    void initUsingSysctl();
-
     bool m_isSupported = false;
     QString m_sysctlDevice;
     QList<int> m_sysctlBrightnessLevels;
-- 
GitLab

