summaryrefslogtreecommitdiff
path: root/sensors-applet/sensors-applet.c
diff options
context:
space:
mode:
authorinfo-cppsp <[email protected]>2018-01-24 21:11:34 +0100
committerraveit65 <[email protected]>2018-01-25 14:59:35 +0100
commitaaddbc0387c7e4089fe1d828ae422f2c88885d9f (patch)
treee95bc90a835060814d600f23ce845d808f037ee7 /sensors-applet/sensors-applet.c
parent826c61d7a97c6dcb4a5136dfc15cc6702515b480 (diff)
downloadmate-sensors-applet-aaddbc0387c7e4089fe1d828ae422f2c88885d9f.tar.bz2
mate-sensors-applet-aaddbc0387c7e4089fe1d828ae422f2c88885d9f.tar.xz
Fix popup shower on removed HDD
Added timer to active sensors, to suppress infinite popups, when a drive is removed from the system, with its sensor still active in msa. fixes #62
Diffstat (limited to 'sensors-applet/sensors-applet.c')
-rw-r--r--sensors-applet/sensors-applet.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/sensors-applet/sensors-applet.c b/sensors-applet/sensors-applet.c
index a401d32..3ddd48d 100644
--- a/sensors-applet/sensors-applet.c
+++ b/sensors-applet/sensors-applet.c
@@ -272,6 +272,8 @@ void sensors_applet_notify_active_sensor(ActiveSensor *active_sensor, NotifType
const gchar *limit_type = NULL;
const gchar *units = NULL;
gdouble limit_value;
+ gdouble seconds;
+ gboolean show_notification = TRUE;
sensors_applet = active_sensor->sensors_applet;
@@ -365,21 +367,35 @@ void sensors_applet_notify_active_sensor(ActiveSensor *active_sensor, NotifType
break;
case SENSOR_INTERFACE_ERROR:
+ /* get time since the last error */
+ seconds = difftime(time(NULL), active_sensor->ierror_ts);
+
+ /* if the last error happened less than 10 seconds ago, don't display this one
+ * this should prevent recurring popups for removed sensors, like USB-HDDs */
+ if (seconds < 11.0) {
+ show_notification = FALSE;
+ }
+
summary = g_strdup_printf(_("Error updating sensor %s"), sensor_label);
message = g_strdup_printf(_("An error occurred while trying to update the value of the sensor %s located at %s."), sensor_label, sensor_path);
timeout_msecs = g_settings_get_int (active_sensor->sensors_applet->settings, TIMEOUT);
+
+ /* update timestamp */
+ time(&(active_sensor->ierror_ts));
break;
default:
g_assert_not_reached();
}
- active_sensor_libnotify_notify(active_sensor,
- notif_type,
- summary,
- message,
- "dialog-warning",
- timeout_msecs);
+ if (show_notification) {
+ active_sensor_libnotify_notify(active_sensor,
+ notif_type,
+ summary,
+ message,
+ "dialog-warning",
+ timeout_msecs);
+ }
g_free(sensor_path);
g_free(sensor_label);