Index: asus.h =================================================================== --- asus.h (revision 445338) +++ asus.h (working copy) @@ -73,6 +73,12 @@ int readProcEntry(const QString &); void clearStruct(asus_state_struct& asus_state); + +#ifdef Q_OS_FREEBSD + int brightness_mib[4]; + int backlight_mib[4]; + int video_mib[4]; +#endif }; #endif Index: asus.cpp =================================================================== --- asus.cpp (revision 445338) +++ asus.cpp (working copy) @@ -33,6 +33,11 @@ #include "asus.h" +#ifdef Q_OS_FREEBSD +#include +#include +#endif + #define ROUND(x) (int(x + 0.5)) namespace KMilo { @@ -50,12 +55,27 @@ kdDebug() << "loading asus kmilo plugin" << endl; // we need to read the /proc file system and store the current values into a struct +#ifdef Q_OS_FREEBSD + /* + * Check if the sysctls are in place by looking up their MIBs. + * Caching the MIBs results in a major speedup. + */ + size_t len = 4; + if ( sysctlnametomib("hw.acpi.asus.lcd_brightness", brightness_mib, &len) == -1 || + sysctlnametomib("hw.acpi.asus.lcd_backlight", backlight_mib, &len) == -1 || + sysctlnametomib("hw.acpi.asus.video_output", video_mib, &len) == -1 ) + { + kdDebug() << "The driver's sysctls don't seem to exist, check that the acpi_asus module is loaded" << endl; + return false; + } +#else QDir dir("/proc/acpi/asus"); if (!dir.exists()) { - kdDebug() << "/proc/acpi/asus doesn't exist, check asus_acpi modules is loaded" << endl; + kdDebug() << "/proc/acpi/asus doesn't exist, check that the asus_acpi module is loaded" << endl; return false; } +#endif else { clearStruct(asus_state); @@ -139,11 +159,25 @@ bool AsusMonitor::readProc(asus_state_struct* asus_state) { +#ifdef Q_OS_FREEBSD + int value; + size_t value_len = sizeof(value); + + if ( sysctl(brightness_mib, 4, &value, &value_len, NULL, 0) != -1 ) + asus_state->brightness = value; + + if ( sysctl(backlight_mib, 4, &value, &value_len, NULL, 0) != -1 ) + asus_state->lcd = value; + + if ( sysctl(video_mib, 4, &value, &value_len, NULL, 0) != -1 ) + asus_state->display = value; +#else asus_state->brightness = readProcEntry(QString("brn")); asus_state->lcd = readProcEntry(QString("lcd")); //disabled because it does not yet work on my S5200N (asus_acpi bug) //asus_state->display = readProcEntry(QString("disp")); //FIXME +#endif return true; }