From a883b9664639b2e80dba9b4e616afba8f3d2163b Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 10 Feb 2009 19:01:39 -0500 Subject: [PATCH] Fixed a status update bug thanks to Evgeni Golov. Added a new state constant, HDAPS_ON. Changed hdaps_update_status to use the new constant when determining whether or not HDAPS has changed states from "on" to "off." --- panel-plugin/hdaps.h | 3 ++- panel-plugin/xfce4-hdaps.c | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/panel-plugin/hdaps.h b/panel-plugin/hdaps.h index 2c900b2..7672b24 100644 --- a/panel-plugin/hdaps.h +++ b/panel-plugin/hdaps.h @@ -21,8 +21,9 @@ #ifndef __HDAPS_H__ #define __HDAPS_H__ -#define HDAPS_ERROR -1 +#define HDAPS_ERROR -1 #define HDAPS_OFF 0 +#define HDAPS_ON 1 #define UNLOAD_HEADS_FMT "/sys/block/%s/device/unload_heads" /* The most devices we'll consider. Gotta stop somewhere. */ diff --git a/panel-plugin/xfce4-hdaps.c b/panel-plugin/xfce4-hdaps.c index 591387f..8dbc74d 100644 --- a/panel-plugin/xfce4-hdaps.c +++ b/panel-plugin/xfce4-hdaps.c @@ -334,6 +334,17 @@ static gboolean hdaps_update_status(HdapsPlugin *hdaps) { /* This just gets the status. */ int status = parse_int_from_file(hdaps->sysfs_file); + /* The value in the sysfs_file represents the number of milliseconds + * that the drive heads will be parked. Of course, this will + * generally count down, and appear different each time we poll. + * + * So, to determine whether or not HDAPS has gone from "on" + * to "off," we treat all values greater than zero the same. + */ + if (status > 0) { + status = HDAPS_ON; + } + if (status != hdaps->previous_status) { /* And we only update the icon if we need to. */ hdaps_set_icon(hdaps, status); -- 2.43.2