diff --git a/src/ppd-utils.c b/src/ppd-utils.c index 553a1e0..ac8c7d9 100644 --- a/src/ppd-utils.c +++ b/src/ppd-utils.c @@ -115,3 +115,38 @@ ppd_utils_find_device (const char *subsystem, return ret; } + +/* Custom fan curves used in asus-wmi module */ +#define ENABLED_FAN_CURVE_PROFILES "/sys/devices/platform/asus-nb-wmi/enabled_fan_curve_profiles" + +gboolean +ppd_utils_can_taint (void) +{ + g_autofree char *fan_curves_file = NULL; + gboolean ret; + + fan_curves_file = ppd_utils_get_sysfs_path (ENABLED_FAN_CURVE_PROFILES); + ret = g_file_test (fan_curves_file, G_FILE_TEST_IS_REGULAR); + g_debug ("%s %s: %s taint", ret ? "Detected" : "Didn't detect", + ENABLED_FAN_CURVE_PROFILES, ret ? "can" : "cannot"); + return ret; +} + +gboolean +ppd_utils_try_taint (void) +{ + g_autofree char *fan_curves_file = NULL; + g_autofree char *contents = NULL; + g_autoptr(GError) error = NULL; + + fan_curves_file = ppd_utils_get_sysfs_path (ENABLED_FAN_CURVE_PROFILES); + if (g_file_get_contents (fan_curves_file, &contents, NULL, &error)) { + if (g_strcmp0 (g_strchomp (contents), "") != 0) { + g_warning ("Custom fan curves are in use, please revert to defaults before reporting any problems"); + return TRUE; + } + } else { + g_debug ("Failed to open %s: %s", ENABLED_FAN_CURVE_PROFILES, error->message); + } + return FALSE; +} diff --git a/src/ppd-utils.h b/src/ppd-utils.h index 9b12e5b..3e32fc3 100644 --- a/src/ppd-utils.h +++ b/src/ppd-utils.h @@ -26,3 +26,6 @@ GFileMonitor *ppd_utils_monitor_sysfs_attr (GUdevDevice *device, GUdevDevice *ppd_utils_find_device (const char *subsystem, GCompareFunc func, gpointer user_data); + +gboolean ppd_utils_can_taint (void); +gboolean ppd_utils_try_taint (void);