mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-12 19:06:36 +00:00
Added sysfs AC adapter support patch (thanks Byron); Small compilation error fix
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1196 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
7f09a767f0
commit
66079c5585
3
AUTHORS
3
AUTHORS
@ -32,6 +32,9 @@ Blondak <blondak_nesercz at users dot sourceforge dot net>
|
|||||||
Bobby Beckmann <bbeckmann at users dot sourceforge dot net>
|
Bobby Beckmann <bbeckmann at users dot sourceforge dot net>
|
||||||
Interface IP and Wireless Quality patch
|
Interface IP and Wireless Quality patch
|
||||||
|
|
||||||
|
Byron Clark <byron_clark at users dot sourceforge dot net>
|
||||||
|
sysfs AC adapter support patch
|
||||||
|
|
||||||
David Carter <boojit at pundo dot com>
|
David Carter <boojit at pundo dot com>
|
||||||
CPU usage being reported incorrectly by top
|
CPU usage being reported incorrectly by top
|
||||||
|
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
# $Id$
|
# $Id$
|
||||||
|
|
||||||
|
2008-06-28
|
||||||
|
* Added sysfs AC adapter support patch (thanks Byron)
|
||||||
|
|
||||||
2008-06-25
|
2008-06-25
|
||||||
* new variables smapi_bat_temp and smapi_bat_power
|
* new variables smapi_bat_temp and smapi_bat_power
|
||||||
* improved docs for freq_dyn* variables
|
* improved docs for freq_dyn* variables
|
||||||
|
@ -2,8 +2,8 @@ dnl $Id$
|
|||||||
|
|
||||||
dnl major, minor and micro version macros.
|
dnl major, minor and micro version macros.
|
||||||
m4_define([conky_version_major], [1])
|
m4_define([conky_version_major], [1])
|
||||||
m4_define([conky_version_minor], [5])
|
m4_define([conky_version_minor], [6])
|
||||||
m4_define([conky_version_micro], [2])
|
m4_define([conky_version_micro], [0])
|
||||||
m4_define([conky_version_tag], [pre]) dnl [] for releases
|
m4_define([conky_version_tag], [pre]) dnl [] for releases
|
||||||
m4_define([conky_version_revision],[_pre@REVISION@])
|
m4_define([conky_version_revision],[_pre@REVISION@])
|
||||||
m4_define([conky_version],
|
m4_define([conky_version],
|
||||||
|
32
src/linux.c
32
src/linux.c
@ -1314,11 +1314,24 @@ void get_acpi_fan(char *p_client_buffer, size_t client_buffer_size)
|
|||||||
snprintf(p_client_buffer, client_buffer_size, "%s", buf);
|
snprintf(p_client_buffer, client_buffer_size, "%s", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define SYSFS_AC_ADAPTER_DIR "/sys/class/power_supply/AC"
|
||||||
#define ACPI_AC_ADAPTER_DIR "/proc/acpi/ac_adapter/"
|
#define ACPI_AC_ADAPTER_DIR "/proc/acpi/ac_adapter/"
|
||||||
|
/* Linux 2.6.25 onwards ac adapter info is in
|
||||||
|
/sys/class/power_supply/AC/
|
||||||
|
On my system I get the following.
|
||||||
|
/sys/class/power_supply/AC/uevent:
|
||||||
|
PHYSDEVPATH=/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:01/PNP0C09:00/ACPI0003:00
|
||||||
|
PHYSDEVBUS=acpi
|
||||||
|
PHYSDEVDRIVER=ac
|
||||||
|
POWER_SUPPLY_NAME=AC
|
||||||
|
POWER_SUPPLY_TYPE=Mains
|
||||||
|
POWER_SUPPLY_ONLINE=1
|
||||||
|
*/
|
||||||
|
|
||||||
void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size)
|
void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size)
|
||||||
{
|
{
|
||||||
static int rep = 0;
|
static int rep = 0;
|
||||||
|
|
||||||
char buf[256];
|
char buf[256];
|
||||||
char buf2[256];
|
char buf2[256];
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
@ -1327,6 +1340,24 @@ void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snprintf(buf2, sizeof(buf2), "%s/uevent", SYSFS_AC_ADAPTER_DIR);
|
||||||
|
fp = open_file(buf2, &rep);
|
||||||
|
if (fp) {
|
||||||
|
/* sysfs processing */
|
||||||
|
while (!feof(fp)) {
|
||||||
|
if (fgets(buf, sizeof(buf), fp) == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (strncmp(buf, "POWER_SUPPLY_ONLINE=", 20) == 0) {
|
||||||
|
int online = 0;
|
||||||
|
sscanf(buf, "POWER_SUPPLY_ONLINE=%d", &online);
|
||||||
|
snprintf(p_client_buffer, client_buffer_size,
|
||||||
|
"%s-line", (online ? "on" : "off"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(fp);
|
||||||
|
} else {
|
||||||
/* yeah, slow... :/ */
|
/* yeah, slow... :/ */
|
||||||
if (!get_first_file_in_a_directory(ACPI_AC_ADAPTER_DIR, buf, &rep)) {
|
if (!get_first_file_in_a_directory(ACPI_AC_ADAPTER_DIR, buf, &rep)) {
|
||||||
snprintf(p_client_buffer, client_buffer_size, "no ac_adapters?");
|
snprintf(p_client_buffer, client_buffer_size, "no ac_adapters?");
|
||||||
@ -1346,6 +1377,7 @@ void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size)
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
snprintf(p_client_buffer, client_buffer_size, "%s", buf);
|
snprintf(p_client_buffer, client_buffer_size, "%s", buf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user