From: Michael Orlitzky Date: Wed, 11 Feb 2009 00:01:39 +0000 (-0500) Subject: Fixed a status update bug thanks to Evgeni Golov. X-Git-Tag: v0.0.4~2 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=a883b9664639b2e80dba9b4e616afba8f3d2163b;p=xfce4-hdaps.git 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." --- 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);