Skip to content

Commit

Permalink
Fix return codes when displaying version, listing power supplies and …
Browse files Browse the repository at this point in the history
…icon types
  • Loading branch information
valr committed Nov 8, 2014
1 parent 8b24836 commit 15e9d67
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
6 changes: 6 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2014-11-08 Valère Monseur <valere.monseur@ymail.com>

* Release 1.4.1

* Fix return codes when displaying version, listing power supplies and icon types

2014-08-17 Valère Monseur <valere.monseur@ymail.com>

* Release 1.4.0
Expand Down
26 changes: 14 additions & 12 deletions cbatticon.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#define CBATTICON_VERSION_NUMBER 1.4.0
#define CBATTICON_VERSION_STRING "1.4.0"
#define CBATTICON_VERSION_NUMBER 1.4.1
#define CBATTICON_VERSION_STRING "1.4.1"

#include <glib/gprintf.h>
#include <gtk/gtk.h>
Expand All @@ -34,7 +34,7 @@
#include <math.h>
#include <syslog.h>

static gboolean get_options (int argc, char **argv);
static gint get_options (int argc, char **argv);
static gboolean get_power_supply (gchar *battery_suffix, gboolean list_power_supply);

static gboolean get_sysattr_string (gchar *path, gchar *attribute, gchar **value);
Expand Down Expand Up @@ -136,7 +136,7 @@ static GTimer *estimation_timer = NULL;
* command line options function
*/

static gboolean get_options (int argc, char **argv)
static gint get_options (int argc, char **argv)
{
GOptionContext *option_context;
GError *error = NULL;
Expand Down Expand Up @@ -170,7 +170,7 @@ static gboolean get_options (int argc, char **argv)
g_printerr ("Cannot parse command line arguments: %s\n", error->message);
g_error_free (error); error = NULL;

return FALSE;
return -1;
}

g_option_context_free (option_context);
Expand All @@ -181,7 +181,7 @@ static gboolean get_options (int argc, char **argv)
g_print ("cbatticon: a lightweight and fast battery icon that sits in your system tray\n");
g_print ("version %s\n", CBATTICON_VERSION_STRING);

return FALSE;
return 0;
}

/* option : list available power supplies (battery and AC) */
Expand All @@ -190,7 +190,7 @@ static gboolean get_options (int argc, char **argv)
g_print ("List of available power supplies:\n");
get_power_supply (NULL, TRUE);

return FALSE;
return 0;
}

/* option : list available icon types */
Expand All @@ -205,7 +205,7 @@ static gboolean get_options (int argc, char **argv)
g_print ("notification\t%s\n", HAS_NOTIFICATION_ICON_TYPE == TRUE ? "available" : "unavailable");
g_print ("symbolic\t%s\n" , HAS_SYMBOLIC_ICON_TYPE == TRUE ? "available" : "unavailable");

return FALSE;
return 0;
}

/* option : set icon type */
Expand Down Expand Up @@ -257,7 +257,7 @@ static gboolean get_options (int argc, char **argv)
g_printerr ("Critical level is higher than low level! They have been reset to default\n");
}

return TRUE;
return 1;
}

/*
Expand Down Expand Up @@ -983,9 +983,11 @@ static gchar* get_icon_name (gint state, gint percentage)

int main (int argc, char **argv)
{
if (get_options (argc, argv) == FALSE) {
return -1;
}
gint ret;

ret = get_options (argc, argv);
if (ret <= 0)
return ret;

#ifdef WITH_NOTIFY
if (configuration.hide_notification == FALSE) {
Expand Down

0 comments on commit 15e9d67

Please sign in to comment.