/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
+ * vim: ts=4 sw=4 noet ai cindent syntax=c
*
* Conky, a system monitor, based on torsmo
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- * vim: ts=4 sw=4 noet ai cindent syntax=c
- *
*/
#include "conky.h"
#include "config.h"
#include "ibm.h"
#include "logging.h"
+#include "temphelper.h"
+#include <ctype.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
+static int ibm_acpi_temps[8];
+
/* Here come the IBM ACPI-specific things. For reference, see
* http://ibm-acpi.sourceforge.net/README
* If IBM ACPI is installed, /proc/acpi/ibm contains the following files:
temperatures: 41 43 31 46 33 -128 29 -128
* Peter Tarjan (ptarjan@citromail.hu) */
-static double last_ibm_acpi_temp_time;
void get_ibm_acpi_temps(void)
{
FILE *fp;
char thermal[128];
- /* don't update too often */
- if (current_update_time - last_ibm_acpi_temp_time < 10.00) {
- return;
- }
- last_ibm_acpi_temp_time = current_update_time;
-
- /* if (!p_client_buffer || client_buffer_size <= 0) {
- return;
- } */
-
snprintf(thermal, 127, "%s/thermal", IBM_ACPI_DIR);
fp = fopen(thermal, "r");
break;
}
if (sscanf(line, "temperatures: %d %d %d %d %d %d %d %d",
- &ibm_acpi.temps[0], &ibm_acpi.temps[1], &ibm_acpi.temps[2],
- &ibm_acpi.temps[3], &ibm_acpi.temps[4], &ibm_acpi.temps[5],
- &ibm_acpi.temps[6], &ibm_acpi.temps[7])) {
+ &ibm_acpi_temps[0], &ibm_acpi_temps[1], &ibm_acpi_temps[2],
+ &ibm_acpi_temps[3], &ibm_acpi_temps[4], &ibm_acpi_temps[5],
+ &ibm_acpi_temps[6], &ibm_acpi_temps[7])) {
break;
}
}
snprintf(p_client_buffer, client_buffer_size, "%d", brightness);
}
+void parse_ibm_temps_arg(struct text_object *obj, const char *arg)
+{
+ if (!isdigit(arg[0]) || strlen(arg) > 1 || atoi(&arg[0]) >= 8) {
+ obj->data.l = 0;
+ NORM_ERR("Invalid temperature sensor! Sensor number must be 0 to 7. "
+ "Using 0 (CPU temp sensor).");
+ } else
+ obj->data.l = atoi(arg);
+}
+
+void print_ibm_temps(struct text_object *obj, char *p, int p_max_size)
+{
+ temp_print(p, p_max_size, ibm_acpi_temps[obj->data.l], TEMP_CELSIUS);
+}