- Add hard disk temperature support (uses sysutils/smartmontools).
- Fix some icons. - Style.
This commit is contained in:
parent
c024a8ca1e
commit
4c3f5f5b09
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=161312
11 changed files with 339 additions and 22 deletions
|
@ -7,6 +7,7 @@
|
|||
|
||||
PORTNAME= sensors-applet
|
||||
PORTVERSION= 1.6.1
|
||||
PORTREVISION= 1
|
||||
CATEGORIES= sysutils
|
||||
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
|
||||
MASTER_SITE_SUBDIR= ${PORTNAME}
|
||||
|
@ -14,16 +15,28 @@ MASTER_SITE_SUBDIR= ${PORTNAME}
|
|||
MAINTAINER= jylefort@FreeBSD.org
|
||||
COMMENT= A GNOME applet displaying hardware sensor values
|
||||
|
||||
RUN_DEPENDS= mbmon:${PORTSDIR}/sysutils/mbmon
|
||||
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
|
||||
CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include -DMBMON_EXECUTABLE=\\\"${LOCALBASE}/bin/mbmon\\\"" \
|
||||
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.* ${WRKSRC}/src
|
||||
@${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>
|
||||
|
|
|
@ -35,7 +35,7 @@ static struct
|
|||
} mbmon_sensors[] = {
|
||||
{ "TEMP0", N_("Main Board"), TEMP_SENSOR, MEM_ICON },
|
||||
{ "TEMP1", N_("CPU"), TEMP_SENSOR, CPU_ICON },
|
||||
{ "TEMP2", N_("PSU"), TEMP_SENSOR, GENERIC_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 },
|
||||
|
@ -49,7 +49,9 @@ static struct
|
|||
};
|
||||
|
||||
static gboolean
|
||||
mbmon_watch_cb (GIOChannel *source, GIOCondition condition, gpointer user_data)
|
||||
mbmon_sensors_interface_watch_cb (GIOChannel *source,
|
||||
GIOCondition condition,
|
||||
gpointer user_data)
|
||||
{
|
||||
char *line;
|
||||
gsize terminator;
|
||||
|
@ -94,7 +96,7 @@ mbmon_watch_cb (GIOChannel *source, GIOCondition condition, gpointer user_data)
|
|||
}
|
||||
|
||||
void
|
||||
mbmon_sensors_interface_init(SensorsApplet *sensors_applet)
|
||||
mbmon_sensors_interface_init (SensorsApplet *sensors_applet)
|
||||
{
|
||||
GError *err = NULL;
|
||||
char *argv[] = { MBMON_EXECUTABLE, "-r", "10", NULL };
|
||||
|
@ -125,7 +127,7 @@ mbmon_sensors_interface_init(SensorsApplet *sensors_applet)
|
|||
|
||||
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_watch_cb, 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++)
|
||||
{
|
||||
|
@ -144,7 +146,7 @@ mbmon_sensors_interface_init(SensorsApplet *sensors_applet)
|
|||
}
|
||||
}
|
||||
|
||||
gdouble
|
||||
double
|
||||
mbmon_sensors_interface_get_sensor_value (const gchar *path,
|
||||
const gchar *id,
|
||||
SensorType type,
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
|
||||
#include "sensors-applet.h"
|
||||
|
||||
void mbmon_sensors_interface_init(SensorsApplet *sensors_applet);
|
||||
gdouble mbmon_sensors_interface_get_sensor_value(const gchar *path,
|
||||
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);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--- src/Makefile.in.orig Fri Mar 24 15:54:47 2006
|
||||
+++ src/Makefile.in Wed May 3 22:09:21 2006
|
||||
@@ -206,21 +206,8 @@
|
||||
+++ 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 \
|
||||
|
@ -20,11 +20,13 @@
|
|||
- smu-sys-sensors-interface.h \
|
||||
- $(sensors_SRC)
|
||||
+ mbmon-sensors-interface.c \
|
||||
+ mbmon-sensors-interface.h
|
||||
+ mbmon-sensors-interface.h \
|
||||
+ smartctl-sensors-interface.c \
|
||||
+ smartctl-sensors-interface.h
|
||||
|
||||
subdir = src
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
@@ -250,13 +237,8 @@
|
||||
@@ -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) \
|
||||
|
@ -36,7 +38,8 @@
|
|||
- hddtemp-sensors-interface.$(OBJEXT) \
|
||||
- smu-sys-sensors-interface.$(OBJEXT) $(am__objects_1)
|
||||
+ sensors-applet-gconf.$(OBJEXT) \
|
||||
+ mbmon-sensors-interface.$(OBJEXT)
|
||||
+ mbmon-sensors-interface.$(OBJEXT) \
|
||||
+ smartctl-sensors-interface.$(OBJEXT)
|
||||
sensors_applet_OBJECTS = $(am_sensors_applet_OBJECTS)
|
||||
sensors_applet_LDADD = $(LDADD)
|
||||
sensors_applet_DEPENDENCIES =
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--- src/sensors-applet.c.orig Fri Mar 24 15:42:32 2006
|
||||
+++ src/sensors-applet.c Wed May 3 22:07:12 2006
|
||||
@@ -29,22 +29,13 @@
|
||||
+++ 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"
|
||||
|
@ -21,10 +21,11 @@
|
|||
-#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 +745,10 @@
|
||||
@@ -754,19 +746,11 @@
|
||||
}
|
||||
|
||||
static void sensors_applet_setup_sensors_interfaces(SensorsApplet *sensors_applet) {
|
||||
|
@ -42,6 +43,7 @@
|
|||
- 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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,18 @@
|
|||
--- src/sensors-applet.h.orig Fri Mar 24 15:44:07 2006
|
||||
+++ src/sensors-applet.h Wed May 3 22:07:18 2006
|
||||
@@ -42,31 +42,15 @@
|
||||
+++ 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 */
|
||||
|
@ -15,6 +27,7 @@
|
|||
- PMU_SYS,
|
||||
- SMU_SYS,
|
||||
+ MBMON,
|
||||
+ SMARTCTL,
|
||||
N_SENSOR_INTERFACES
|
||||
} SensorInterface;
|
||||
|
||||
|
@ -30,7 +43,8 @@
|
|||
- "omnibook",
|
||||
- "pmu-sys",
|
||||
- "smu-sys",
|
||||
+ "mbmon"
|
||||
+ "mbmon",
|
||||
+ "smartctl"
|
||||
};
|
||||
|
||||
/* enumeration used to identify columns in the GtkTreeStore data
|
||||
|
|
53
sysutils/sensors-applet/files/smartctl-helper.c
Normal file
53
sysutils/sensors-applet/files/smartctl-helper.c
Normal file
|
@ -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;
|
||||
}
|
198
sysutils/sensors-applet/files/smartctl-sensors-interface.c
Normal file
198
sysutils/sensors-applet/files/smartctl-sensors-interface.c
Normal file
|
@ -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;
|
||||
}
|
30
sysutils/sensors-applet/files/smartctl-sensors-interface.h
Normal file
30
sysutils/sensors-applet/files/smartctl-sensors-interface.h
Normal file
|
@ -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*/
|
|
@ -1,7 +1,8 @@
|
|||
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 port.
|
||||
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/
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
libdata/bonobo/servers/SensorsApplet.server
|
||||
libexec/sensors-applet
|
||||
libexec/smartctl-helper
|
||||
share/gnome/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
|
||||
|
|
Loading…
Reference in a new issue