** psensor: fixed compilation with AMD/ATI GPU monitoring support
(submitted by Lubos Stanek).
** psensor: default log level set to LOG_WARN.
-** few code refactoring and cleanup
+** few code refactoring and cleanup.
** psensor: added support of status tray icon for DE not supporting
Ubuntu Application Indicator.
top_srcdir = ..
-prefix = /tmp/r
+prefix = /usr/local
exec_prefix = ${prefix}
datarootdir = ${prefix}/share
datadir = ${datarootdir}
#include "color.h"
-#define SENSORLIST_POSITION_RIGHT 0
-#define SENSORLIST_POSITION_LEFT 1
-#define SENSORLIST_POSITION_TOP 2
-#define SENSORLIST_POSITION_BOTTOM 3
+enum sensorlist_position {
+ SENSORLIST_POSITION_RIGHT,
+ SENSORLIST_POSITION_LEFT,
+ SENSORLIST_POSITION_TOP,
+ SENSORLIST_POSITION_BOTTOM
+};
struct config {
struct color *graph_bgcolor;
/*
Position of the sensors list table
*/
- int sensorlist_position;
+ enum sensorlist_position sensorlist_position;
int window_decoration_enabled;
int window_keep_below_enabled;
fprintf(stdf, "[%ld] %s %s\n", tv.tv_sec, lvl_str, buffer);
}
}
+
+void log_debug(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ log_printf(LOG_ERR, fmt, ap);
+ va_end(ap);
+}
void log_open(const char *path);
void log_printf(int lvl, const char *fmt, ...);
+void log_debug(const char *fmt, ...);
void log_close();
{
if (log_level == LOG_DEBUG)
while (*sensors) {
- log_printf(LOG_DEBUG, "%s %.2f",
+ log_printf(LOG_DEBUG, "Measure: %s %.2f",
(*sensors)->name,
psensor_get_current_value(*sensors));
gtk_init(NULL, NULL);
-#ifdef HAVE_LIBNOTIFY
- ui.notification_last_time = NULL;
-#endif
-
ui.sensors_mutex = g_mutex_new();
config_init();
int graph_update_interval;
GMutex *sensors_mutex;
-
-#ifdef HAVE_LIBNOTIFY
- /* Time of the last notification */
- struct timeval *notification_last_time;
-#endif
};
/*
#include "ui.h"
#include "ui_notify.h"
+/* Time of the last notification. */
+static struct timeval last_notification_tv;
+
void ui_notify(struct psensor *sensor, struct ui_psensor *ui)
{
- struct timeval *t = malloc(sizeof(struct timeval));
+ struct timeval t;
char *name;
NotifyNotification *notif;
- if (gettimeofday(t, NULL) != 0) {
- fprintf(stderr, _("ERROR: failed gettimeofday\n"));
- free(t);
+ log_debug("ui_notify() last_notification %d",
+ last_notification_tv.tv_sec);
+ if (gettimeofday(&t, NULL) != 0) {
+ log_printf(LOG_ERR, _("gettimeofday failed"));
return;
}
- if (!ui->notification_last_time) {
- /* first notification */
- ui->notification_last_time = t;
- } else {
-
- if (t->tv_sec - ui->notification_last_time->tv_sec < 60) {
- /* last notification less than 1mn ago */
- free(t);
- return;
- } else {
- /* last notification more than 1mn ago */
- free(ui->notification_last_time);
- ui->notification_last_time = t;
- }
- }
+ if (!last_notification_tv.tv_sec
+ || t.tv_sec - last_notification_tv.tv_sec >= 60)
+ last_notification_tv = t;
+ else
+ return ;
if (notify_is_initted() == FALSE)
notify_init("psensor");
* only 3 parameters.
*/
#if NOTIFY_CHECK_VERSION(0, 7, 0)
- notif = notify_notification_new(_("Temperature alert"),
- name,
- NULL);
+ notif = notify_notification_new
+ (_("Temperature alert"), name, NULL);
#else
notif = notify_notification_new(_("Temperature alert"),
name,
NULL,
GTK_WIDGET(ui->main_window));
#endif
+ log_debug("ui_notify() notif_notification_new %s", name);
notify_notification_show(notif, NULL);
g_object_unref(notif);
+ } else {
+ log_printf(LOG_ERR, "notify not initted");
}
}