diff options
author | mezz <mezz@df743ca5-7f9a-e211-a948-0013205c9059> | 2007-08-07 04:43:19 +0800 |
---|---|---|
committer | mezz <mezz@df743ca5-7f9a-e211-a948-0013205c9059> | 2007-08-07 04:43:19 +0800 |
commit | 0b084bcd09a6dda9e71db7da2b802e18c6bd55ab (patch) | |
tree | 0e16b8350c1e3a2c0ef149566a0bf336475af419 /sysutils/sensors-applet | |
parent | 664243d83ec44a146d7cfa4b00f8426084630860 (diff) | |
download | marcuscom-ports-0b084bcd09a6dda9e71db7da2b802e18c6bd55ab.tar marcuscom-ports-0b084bcd09a6dda9e71db7da2b802e18c6bd55ab.tar.gz marcuscom-ports-0b084bcd09a6dda9e71db7da2b802e18c6bd55ab.tar.bz2 marcuscom-ports-0b084bcd09a6dda9e71db7da2b802e18c6bd55ab.tar.lz marcuscom-ports-0b084bcd09a6dda9e71db7da2b802e18c6bd55ab.tar.xz marcuscom-ports-0b084bcd09a6dda9e71db7da2b802e18c6bd55ab.tar.zst marcuscom-ports-0b084bcd09a6dda9e71db7da2b802e18c6bd55ab.zip |
share/gnome/ -> share/.
git-svn-id: svn://creme-brulee.marcuscom.com/ports/trunk@9363 df743ca5-7f9a-e211-a948-0013205c9059
Diffstat (limited to 'sysutils/sensors-applet')
-rw-r--r-- | sysutils/sensors-applet/Makefile | 42 | ||||
-rw-r--r-- | sysutils/sensors-applet/distinfo | 3 | ||||
-rw-r--r-- | sysutils/sensors-applet/files/mbmon-sensors-interface.c | 163 | ||||
-rw-r--r-- | sysutils/sensors-applet/files/mbmon-sensors-interface.h | 30 | ||||
-rw-r--r-- | sysutils/sensors-applet/files/patch-src_Makefile.in | 45 | ||||
-rw-r--r-- | sysutils/sensors-applet/files/patch-src_sensors-applet.c | 49 | ||||
-rw-r--r-- | sysutils/sensors-applet/files/patch-src_sensors-applet.h | 50 | ||||
-rw-r--r-- | sysutils/sensors-applet/files/smartctl-helper.c | 53 | ||||
-rw-r--r-- | sysutils/sensors-applet/files/smartctl-sensors-interface.c | 198 | ||||
-rw-r--r-- | sysutils/sensors-applet/files/smartctl-sensors-interface.h | 30 | ||||
-rw-r--r-- | sysutils/sensors-applet/pkg-descr | 10 | ||||
-rw-r--r-- | sysutils/sensors-applet/pkg-plist | 33 |
12 files changed, 706 insertions, 0 deletions
diff --git a/sysutils/sensors-applet/Makefile b/sysutils/sensors-applet/Makefile new file mode 100644 index 000000000..16a5532f6 --- /dev/null +++ b/sysutils/sensors-applet/Makefile @@ -0,0 +1,42 @@ +# New ports collection makefile for: sensors-applet +# Date created: 03 May 2006 +# Whom: Jean-Yves Lefort <jylefort@FreeBSD.org> +# +# $FreeBSD$ +# + +PORTNAME= sensors-applet +PORTVERSION= 1.6.1 +PORTREVISION= 4 +CATEGORIES= sysutils +MASTER_SITES= ${MASTER_SITE_SOURCEFORGE} +MASTER_SITE_SUBDIR= ${PORTNAME} + +MAINTAINER= jylefort@FreeBSD.org +COMMENT= A GNOME applet displaying hardware sensor values + +RUN_DEPENDS= mbmon:${PORTSDIR}/sysutils/mbmon \ + smartctl:${PORTSDIR}/sysutils/smartmontools + +USE_X_PREFIX= yes +USE_GNOME= gnomehack gnomeprefix intlhack gnomepanel +GNU_CONFIGURE= yes +USE_GMAKE= yes +DEFINES= -DMBMON_EXECUTABLE=\\\"${LOCALBASE}/bin/mbmon\\\" \ + -DSMARTCTL_HELPER=\\\"${PREFIX}/libexec/smartctl-helper\\\" +CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include ${DEFINES}" \ + LDFLAGS="-L${LOCALBASE}/lib" + +post-patch: + @${CP} -f ${FILESDIR}/mbmon-sensors-interface.* \ + ${FILESDIR}/smartctl-sensors-interface.* ${WRKSRC}/src + +post-build: + ${CC} ${CFLAGS} -DSMARTCTL=\"${LOCALBASE}/sbin/smartctl\" \ + -o ${WRKSRC}/smartctl-helper ${FILESDIR}/smartctl-helper.c + +post-install: + ${INSTALL_PROGRAM} ${WRKSRC}/smartctl-helper ${PREFIX}/libexec + ${CHMOD} u+s ${PREFIX}/libexec/smartctl-helper + +.include <bsd.port.mk> diff --git a/sysutils/sensors-applet/distinfo b/sysutils/sensors-applet/distinfo new file mode 100644 index 000000000..631935ff2 --- /dev/null +++ b/sysutils/sensors-applet/distinfo @@ -0,0 +1,3 @@ +MD5 (sensors-applet-1.6.1.tar.gz) = b1feac15a8354fe0f3fd62a16b38293d +SHA256 (sensors-applet-1.6.1.tar.gz) = 1ac5c6760e976366a1f12024325ba83a22e46e7f84f59dbdc89eb985c04260d2 +SIZE (sensors-applet-1.6.1.tar.gz) = 222358 diff --git a/sysutils/sensors-applet/files/mbmon-sensors-interface.c b/sysutils/sensors-applet/files/mbmon-sensors-interface.c new file mode 100644 index 000000000..6c48af424 --- /dev/null +++ b/sysutils/sensors-applet/files/mbmon-sensors-interface.c @@ -0,0 +1,163 @@ +/* + * Copyright (C) 2006 Jean-Yves Lefort <jylefort@FreeBSD.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <stdlib.h> + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif /* HAVE_CONFIG_H */ + +#include "mbmon-sensors-interface.h" +#include "sensors-applet.h" + +static struct +{ + const char *name; + const char *label; + SensorType type; + const char *icon; + double value; +} mbmon_sensors[] = { + { "TEMP0", N_("Main Board"), TEMP_SENSOR, MEM_ICON }, + { "TEMP1", N_("CPU"), TEMP_SENSOR, CPU_ICON }, + { "TEMP2", N_("PSU"), TEMP_SENSOR, CASE_ICON }, + { "FAN0", N_("Main Board Fan"), FAN_SENSOR, FAN_ICON }, + { "FAN1", N_("CPU Fan"), FAN_SENSOR, FAN_ICON }, + { "FAN2", N_("PSU Fan"), FAN_SENSOR, FAN_ICON }, + { "VC0", N_("Vc0"), VOLTAGE_SENSOR, VOLTAGE_ICON }, + { "VC1", N_("Vc1"), VOLTAGE_SENSOR, VOLTAGE_ICON }, + { "V33", N_("V33"), VOLTAGE_SENSOR, VOLTAGE_ICON }, + { "V50P", N_("V50P"), VOLTAGE_SENSOR, VOLTAGE_ICON }, + { "V12P", N_("V12P"), VOLTAGE_SENSOR, VOLTAGE_ICON }, + { "V12N", N_("V12N"), VOLTAGE_SENSOR, VOLTAGE_ICON }, + { "V50N", N_("V50N"), VOLTAGE_SENSOR, VOLTAGE_ICON } +}; + +static gboolean +mbmon_sensors_interface_watch_cb (GIOChannel *source, + GIOCondition condition, + gpointer user_data) +{ + char *line; + gsize terminator; + + while (g_io_channel_read_line(source, &line, NULL, &terminator, NULL) == G_IO_STATUS_NORMAL) + { + char *space; + + line[terminator] = 0; + + space = strchr(line, ' '); + if (space) + { + int name_len; + int i; + + name_len = space - line; + for (i = 0; i < G_N_ELEMENTS(mbmon_sensors); i++) + if (! strncmp(mbmon_sensors[i].name, line, name_len)) + { + char *value_start; + + value_start = strstr(space + 1, ": "); + if (value_start) + { + double value; + char *end; + + value = strtod(value_start + 2, &end); + if (*end == 0) + mbmon_sensors[i].value = value; + } + + break; + } + } + + g_free(line); + } + + return TRUE; /* keep source */ +} + +void +mbmon_sensors_interface_init (SensorsApplet *sensors_applet) +{ + GError *err = NULL; + char *argv[] = { MBMON_EXECUTABLE, "-r", "10", NULL }; + int mbmon_stdout; + GIOChannel *channel; + int i; + + sensors_applet_register_sensors_interface(sensors_applet, + MBMON, + mbmon_sensors_interface_get_sensor_value); + + if (! g_spawn_async_with_pipes(NULL, + argv, + NULL, + 0, + NULL, + NULL, + NULL, + NULL, + &mbmon_stdout, + NULL, + &err)) + { + g_warning("Unable to execute mbmon: %s", err->message); + g_error_free(err); + return; + } + + channel = g_io_channel_unix_new(mbmon_stdout); + g_io_channel_set_flags(channel, G_IO_FLAG_NONBLOCK, NULL); + g_io_add_watch(channel, G_IO_IN, mbmon_sensors_interface_watch_cb, NULL); + + for (i = 0; i < G_N_ELEMENTS(mbmon_sensors); i++) + { + char *path; + + path = g_strdup_printf("/mbmon/%s", mbmon_sensors[i].name); + sensors_applet_add_sensor(sensors_applet, + path, + mbmon_sensors[i].name, + mbmon_sensors[i].label, + MBMON, + TRUE, + mbmon_sensors[i].type, + mbmon_sensors[i].icon); + g_free(path); + } +} + +double +mbmon_sensors_interface_get_sensor_value (const gchar *path, + const gchar *id, + SensorType type, + GError **error) +{ + int i; + + for (i = 0; i < G_N_ELEMENTS(mbmon_sensors); i++) + if (! strcmp(mbmon_sensors[i].name, id)) + return mbmon_sensors[i].value; + + g_set_error(error, 0, 0, "Unknown sensor \"%s\"", id); + return 0; +} diff --git a/sysutils/sensors-applet/files/mbmon-sensors-interface.h b/sysutils/sensors-applet/files/mbmon-sensors-interface.h new file mode 100644 index 000000000..3bf7df9b7 --- /dev/null +++ b/sysutils/sensors-applet/files/mbmon-sensors-interface.h @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2006 Jean-Yves Lefort <jylefort@FreeBSD.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef MBMON_SENSORS_INTERFACE_H +#define MBMON_SENSORS_INTERFACE_H + +#include "sensors-applet.h" + +void mbmon_sensors_interface_init (SensorsApplet *sensors_applet); +double mbmon_sensors_interface_get_sensor_value (const gchar *path, + const gchar *id, + SensorType type, + GError **error); + +#endif /* MBMON_SENSORS_INTERFACE_H*/ diff --git a/sysutils/sensors-applet/files/patch-src_Makefile.in b/sysutils/sensors-applet/files/patch-src_Makefile.in new file mode 100644 index 000000000..9cc2997d7 --- /dev/null +++ b/sysutils/sensors-applet/files/patch-src_Makefile.in @@ -0,0 +1,45 @@ +--- src/Makefile.in.orig Fri Mar 24 15:54:47 2006 ++++ src/Makefile.in Thu May 4 05:03:13 2006 +@@ -206,21 +206,10 @@ + sensors-applet.h \ + sensors-applet-gconf.c \ + sensors-applet-gconf.h \ +- acpi-sensors-interface.c \ +- acpi-sensors-interface.h \ +- ibm-acpi-sensors-interface.c \ +- ibm-acpi-sensors-interface.h \ +- omnibook-sensors-interface.c \ +- omnibook-sensors-interface.h \ +- pmu-sys-sensors-interface.c \ +- pmu-sys-sensors-interface.h \ +- i8k-sensors-interface.c \ +- i8k-sensors-interface.h \ +- hddtemp-sensors-interface.c \ +- hddtemp-sensors-interface.h \ +- smu-sys-sensors-interface.c \ +- smu-sys-sensors-interface.h \ +- $(sensors_SRC) ++ mbmon-sensors-interface.c \ ++ mbmon-sensors-interface.h \ ++ smartctl-sensors-interface.c \ ++ smartctl-sensors-interface.h + + subdir = src + ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +@@ -250,13 +239,9 @@ + am_sensors_applet_OBJECTS = main.$(OBJEXT) about-dialog.$(OBJEXT) \ + active-sensor.$(OBJEXT) prefs-dialog.$(OBJEXT) \ + sensor-config-dialog.$(OBJEXT) sensors-applet.$(OBJEXT) \ +- sensors-applet-gconf.$(OBJEXT) acpi-sensors-interface.$(OBJEXT) \ +- ibm-acpi-sensors-interface.$(OBJEXT) \ +- omnibook-sensors-interface.$(OBJEXT) \ +- pmu-sys-sensors-interface.$(OBJEXT) \ +- i8k-sensors-interface.$(OBJEXT) \ +- hddtemp-sensors-interface.$(OBJEXT) \ +- smu-sys-sensors-interface.$(OBJEXT) $(am__objects_1) ++ sensors-applet-gconf.$(OBJEXT) \ ++ mbmon-sensors-interface.$(OBJEXT) \ ++ smartctl-sensors-interface.$(OBJEXT) + sensors_applet_OBJECTS = $(am_sensors_applet_OBJECTS) + sensors_applet_LDADD = $(LDADD) + sensors_applet_DEPENDENCIES = diff --git a/sysutils/sensors-applet/files/patch-src_sensors-applet.c b/sysutils/sensors-applet/files/patch-src_sensors-applet.c new file mode 100644 index 000000000..895940b24 --- /dev/null +++ b/sysutils/sensors-applet/files/patch-src_sensors-applet.c @@ -0,0 +1,49 @@ +--- src/sensors-applet.c.orig Fri Mar 24 15:42:32 2006 ++++ src/sensors-applet.c Thu May 4 04:57:32 2006 +@@ -29,22 +29,14 @@ + #include "sensors-applet.h" + #include "active-sensor.h" + #include "sensors-applet-gconf.h" +-#include "acpi-sensors-interface.h" + + /* use libsensors if available, otherwise manually find sensors */ + #ifdef HAVE_LIBSENSORS + #include "libsensors-sensors-interface.h" +-#else +-#include "i2c-sys-sensors-interface.h" +-#include "i2c-proc-sensors-interface.h" + #endif + +-#include "i8k-sensors-interface.h" +-#include "ibm-acpi-sensors-interface.h" +-#include "omnibook-sensors-interface.h" +-#include "pmu-sys-sensors-interface.h" +-#include "smu-sys-sensors-interface.h" +-#include "hddtemp-sensors-interface.h" ++#include "mbmon-sensors-interface.h" ++#include "smartctl-sensors-interface.h" + #include "prefs-dialog.h" + #include "about-dialog.h" + +@@ -754,19 +746,11 @@ + } + + static void sensors_applet_setup_sensors_interfaces(SensorsApplet *sensors_applet) { +- acpi_sensors_interface_init(sensors_applet); +- hddtemp_sensors_interface_init(sensors_applet); + #ifdef HAVE_LIBSENSORS + libsensors_sensors_interface_init(sensors_applet); +-#else +- i2c_proc_sensors_interface_init(sensors_applet); +- i2c_sys_sensors_interface_init(sensors_applet); + #endif +- i8k_sensors_interface_init(sensors_applet); +- ibm_acpi_sensors_interface_init(sensors_applet); +- omnibook_sensors_interface_init(sensors_applet); +- pmu_sys_sensors_interface_init(sensors_applet); +- smu_sys_sensors_interface_init(sensors_applet); ++ mbmon_sensors_interface_init(sensors_applet); ++ smartctl_sensors_interface_init(sensors_applet); + } + + diff --git a/sysutils/sensors-applet/files/patch-src_sensors-applet.h b/sysutils/sensors-applet/files/patch-src_sensors-applet.h new file mode 100644 index 000000000..7e73a9fcd --- /dev/null +++ b/sysutils/sensors-applet/files/patch-src_sensors-applet.h @@ -0,0 +1,50 @@ +--- src/sensors-applet.h.orig Fri Mar 24 15:44:07 2006 ++++ src/sensors-applet.h Thu May 4 04:58:05 2006 +@@ -32,41 +32,28 @@ + #define CPU_ICON PIXMAPS_DIR "cpu-icon.png" + #define HDD_ICON PIXMAPS_DIR "hdd-icon.png" + #define BATTERY_ICON PIXMAPS_DIR "battery-icon.png" +-#define MEM_ICON PIXMAPS_DIR "mem-icon.png" ++#define MEM_ICON PIXMAPS_DIR "memory-icon.png" + #define GPU_ICON PIXMAPS_DIR "gpu-icon.png" + #define GENERIC_ICON PIXMAPS_DIR "generic-icon.png" + #define FAN_ICON PIXMAPS_DIR "fan-icon.png" ++#define CASE_ICON PIXMAPS_DIR "case-icon.png" + #define VOLTAGE_ICON NULL + + #define DEFAULT_ICON_SIZE 24 + + typedef enum { + UNUSED = 0, /* as a flag to test against later */ +- ACPI, +- HDDTEMP, +- I2C_SYS, +- I2C_PROC, +- IBM_ACPI, +- I8K, + LIBSENSORS, +- OMNIBOOK, +- PMU_SYS, +- SMU_SYS, ++ MBMON, ++ SMARTCTL, + N_SENSOR_INTERFACES + } SensorInterface; + + static const gchar *sensor_interface[] = { + "unused", +- "acpi", +- "hddtemp", +- "i2c-sys", +- "i2c-proc", +- "ibm-acpi", +- "i8k", + "libsensors", +- "omnibook", +- "pmu-sys", +- "smu-sys", ++ "mbmon", ++ "smartctl" + }; + + /* enumeration used to identify columns in the GtkTreeStore data diff --git a/sysutils/sensors-applet/files/smartctl-helper.c b/sysutils/sensors-applet/files/smartctl-helper.c new file mode 100644 index 000000000..fe9aa4a3e --- /dev/null +++ b/sysutils/sensors-applet/files/smartctl-helper.c @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2006 Jean-Yves Lefort <jylefort@FreeBSD.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <unistd.h> + +static void +smartctl_helper_usage (void) +{ + fprintf(stderr, "Usage: smartctl-helper enable|attributes DEVICE\n"); + exit(1); +} + +int +main (int argc, char **argv) +{ + if (argc != 3) + smartctl_helper_usage(); + + if (! strcmp(argv[1], "enable")) + { + char *smartctl_argv[] = { "smartctl", "-s", "on", argv[2], NULL }; + execve(SMARTCTL, smartctl_argv, NULL); + } + else if (! strcmp(argv[1], "attributes")) + { + char *smartctl_argv[] = { "smartctl", "-A", argv[2], NULL }; + execve(SMARTCTL, smartctl_argv, NULL); + } + else + smartctl_helper_usage(); + + /* execve failed */ + fprintf(stderr, "Unable to execute %s\n", SMARTCTL); + return 1; +} diff --git a/sysutils/sensors-applet/files/smartctl-sensors-interface.c b/sysutils/sensors-applet/files/smartctl-sensors-interface.c new file mode 100644 index 000000000..c3c4b3de8 --- /dev/null +++ b/sysutils/sensors-applet/files/smartctl-sensors-interface.c @@ -0,0 +1,198 @@ +/* + * Copyright (C) 2006 Jean-Yves Lefort <jylefort@FreeBSD.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <stdlib.h> +#include <time.h> + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif /* HAVE_CONFIG_H */ + +#include "smartctl-sensors-interface.h" +#include "sensors-applet.h" + +/* be gentle */ +#define POLL_INTERVAL 30 + +typedef struct +{ + time_t last_poll; + double value; +} SensorInfo; + +static GHashTable *sensors; + +static gboolean +smartctl_sensors_interface_run (const char *command, + const char *device, + char **output) +{ + char *argv[4]; + GSpawnFlags flags = G_SPAWN_STDERR_TO_DEV_NULL; + char *_output = NULL; + int exit_status; + + g_return_val_if_fail(command != NULL, FALSE); + g_return_val_if_fail(device != NULL, FALSE); + + argv[0] = SMARTCTL_HELPER; + argv[1] = (char *) command; + argv[2] = (char *) device; + argv[3] = NULL; + + if (! output) + flags |= G_SPAWN_STDOUT_TO_DEV_NULL; + + if (g_spawn_sync(NULL, argv, NULL, flags, NULL, NULL, output ? &_output : NULL, NULL, &exit_status, NULL)) + { + if (exit_status == 0) + { + if (output) + *output = _output; + + return TRUE; + } + g_free(_output); + } + + return FALSE; +} + +static gboolean +smartctl_sensors_interface_get_temperature (const char *device, double *temp) +{ + char *output; + char **lines; + int i; + gboolean status = FALSE; + + g_return_val_if_fail(device != NULL, FALSE); + + if (! smartctl_sensors_interface_run("attributes", device, &output)) + return FALSE; + + lines = g_strsplit(output, "\n", 0); + g_free(output); + + for (i = 0; lines[i]; i++) + if (g_str_has_prefix(lines[i], "194 Temperature_Celsius")) + { + char *p; + + p = strrchr(lines[i], ' '); + if (p) + { + double _temp; + char *end; + + _temp = strtod(p + 1, &end); + if (*end == 0) + { + status = TRUE; + if (temp) + *temp = _temp; + } + } + + break; + } + g_strfreev(lines); + + return status; +} + +static void +smartctl_sensors_interface_disk_init (SensorsApplet *sensors_applet, + const char *disk, + int unit) +{ + char *device; + + g_return_if_fail(sensors_applet != NULL); + g_return_if_fail(disk != NULL); + + device = g_strdup_printf("/dev/%s%i", disk, unit); + if (g_file_test(device, G_FILE_TEST_EXISTS) + && smartctl_sensors_interface_run("enable", device, NULL) + && smartctl_sensors_interface_get_temperature(device, NULL)) + { + char *path; + char *label; + + path = g_strdup_printf("/smartctl%s", device); + label = g_strdup_printf("%s%i", disk, unit); + + sensors_applet_add_sensor(sensors_applet, + path, + device, + label, + SMARTCTL, + TRUE, + TEMP_SENSOR, + HDD_ICON); + + g_free(path); + g_free(label); + } + g_free(device); +} + +void +smartctl_sensors_interface_init (SensorsApplet *sensors_applet) +{ + int i; + + sensors = g_hash_table_new(g_str_hash, g_str_equal); + + sensors_applet_register_sensors_interface(sensors_applet, + SMARTCTL, + smartctl_sensors_interface_get_sensor_value); + + /* smartctl supports ad(4) and da(4) disks */ + for (i = 0; i < 10; i++) + { + smartctl_sensors_interface_disk_init(sensors_applet, "ad", i); + smartctl_sensors_interface_disk_init(sensors_applet, "da", i); + } +} + +double +smartctl_sensors_interface_get_sensor_value (const gchar *path, + const gchar *id, + SensorType type, + GError **error) +{ + SensorInfo *info; + time_t now; + + info = g_hash_table_lookup(sensors, id); + if (! info) + { + info = g_new0(SensorInfo, 1); + g_hash_table_insert(sensors, g_strdup(id), info); + } + + now = time(NULL); + if (now == -1 || now - info->last_poll >= POLL_INTERVAL) + { + info->last_poll = now; + smartctl_sensors_interface_get_temperature(id, &info->value); + } + + return info->value; +} diff --git a/sysutils/sensors-applet/files/smartctl-sensors-interface.h b/sysutils/sensors-applet/files/smartctl-sensors-interface.h new file mode 100644 index 000000000..03b3b099a --- /dev/null +++ b/sysutils/sensors-applet/files/smartctl-sensors-interface.h @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2006 Jean-Yves Lefort <jylefort@FreeBSD.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SMARTCTL_SENSORS_INTERFACE_H +#define SMARTCTL_SENSORS_INTERFACE_H + +#include "sensors-applet.h" + +void smartctl_sensors_interface_init (SensorsApplet *sensors_applet); +double smartctl_sensors_interface_get_sensor_value (const gchar *path, + const gchar *id, + SensorType type, + GError **error); + +#endif /* SMARTCTL_SENSORS_INTERFACE_H*/ diff --git a/sysutils/sensors-applet/pkg-descr b/sysutils/sensors-applet/pkg-descr new file mode 100644 index 000000000..a7dbe3e0a --- /dev/null +++ b/sysutils/sensors-applet/pkg-descr @@ -0,0 +1,10 @@ +GNOME Sensors Applet is an applet for the GNOME Panel to display readings from +hardware sensors, including CPU temperature, fan speeds and voltage readings. + +On FreeBSD, sensor values are obtained from the sysutils/mbmon (for +motherboards) and sysutils/smartmontools (for hard disks) ports. + +WWW: http://sensors-applet.sourceforge.net/ + +- Jean-Yves Lefort +jylefort@FreeBSD.org diff --git a/sysutils/sensors-applet/pkg-plist b/sysutils/sensors-applet/pkg-plist new file mode 100644 index 000000000..fae823ba7 --- /dev/null +++ b/sysutils/sensors-applet/pkg-plist @@ -0,0 +1,33 @@ +libdata/bonobo/servers/SensorsApplet.server +libexec/sensors-applet +libexec/smartctl-helper +share/gnome-2.0/ui/SensorsApplet.xml +share/gnome/help/sensors-applet/C/figures/applet_in_panel.png +share/gnome/help/sensors-applet/C/legal.xml +share/gnome/help/sensors-applet/C/sensors-applet.xml +share/omf/sensors-applet/sensors-applet-C.omf +share/pixmaps/sensors-applet/battery-icon.png +share/pixmaps/sensors-applet/case-icon.png +share/pixmaps/sensors-applet/cpu-icon.png +share/pixmaps/sensors-applet/fan-icon.png +share/pixmaps/sensors-applet/hdd-icon.png +share/pixmaps/sensors-applet/high-temp-icon.png +share/pixmaps/sensors-applet/low-temp-icon.png +share/pixmaps/sensors-applet/memory-icon.png +share/pixmaps/sensors-applet/normal-temp-icon.png +share/pixmaps/sensors-applet/sensors-applet-icon.png +share/pixmaps/sensors-applet/very-high-temp-icon.png +share/pixmaps/sensors-applet/very-low-temp-icon.png +share/locale/de/LC_MESSAGES/sensors-applet.mo +share/locale/es/LC_MESSAGES/sensors-applet.mo +share/locale/fi/LC_MESSAGES/sensors-applet.mo +share/locale/fr/LC_MESSAGES/sensors-applet.mo +share/locale/it/LC_MESSAGES/sensors-applet.mo +share/locale/pl/LC_MESSAGES/sensors-applet.mo +share/locale/ro/LC_MESSAGES/sensors-applet.mo +share/locale/ru/LC_MESSAGES/sensors-applet.mo +@dirrm share/gnome/help/sensors-applet/C/figures +@dirrm share/gnome/help/sensors-applet/C +@dirrm share/gnome/help/sensors-applet +@dirrm share/omf/sensors-applet +@dirrm share/pixmaps/sensors-applet |