From bbaa68a5c03d0e972ca354f89abd630dd62f4555 Mon Sep 17 00:00:00 2001 From: Erik Westrup Date: Mon, 23 Sep 2013 23:57:39 +0200 Subject: [PATCH] Allow one decimal place to daemon's --timeout argument e.g. 'volnoti -t 1.5'. --- src/daemon.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/daemon.c b/src/daemon.c index b530fa4..3508558 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -132,7 +132,7 @@ gboolean volume_object_notify(VolumeObject* obj, print_debug("Creating new notification...", obj->debug); obj->notification = create_notification(obj->settings); gtk_widget_realize(GTK_WIDGET(obj->notification)); - g_timeout_add(1000, (GSourceFunc) time_handler, (gpointer) obj); + g_timeout_add(100, (GSourceFunc) time_handler, (gpointer) obj); print_debug_ok(obj->debug); } @@ -170,7 +170,7 @@ static void print_usage(const char* filename, int failure) { " -n\t\t--no-daemon\t\tdo not daemonize\n" "\n" "Configuration:\n" - " -t \t--timeout \t\tnotification timeout in seconds\n" + " -t \t--timeout \t\tnotification timeout in seconds with one optional decimal place\n" " -a \t--alpha \t\ttransparency level (0.0 - 1.0, default %.2f)\n" " -r \t--corner-radius \tradius of the round corners in pixels (default %d)\n" , filename, settings.alpha, settings.corner_radius); @@ -182,6 +182,7 @@ static void print_usage(const char* filename, int failure) { int main(int argc, char* argv[]) { Settings settings = get_default_settings(); + float timeout_in; int timeout = 3; void *options = gopt_sort(&argc, (const char**) argv, gopt_start( @@ -197,8 +198,12 @@ int main(int argc, char* argv[]) { int no_daemon = gopt(options, 'n'); if (gopt(options, 't')) { - if (sscanf(gopt_arg_i(options, 't', 0), "%d", &timeout) != 1) + if (sscanf(gopt_arg_i(options, 't', 0), "%f", &timeout_in) == 1 + && timeout_in > 0.0f) { + timeout = (int) (timeout_in * 10); + } else { print_usage(argv[0], TRUE); + } } if (gopt(options, 'a')) {