]> mj.ucw.cz Git - teatimer.git/commitdiff
Add option to set default name
authorJiri Kalvoda <jirikalvoda@kam.mff.cuni.cz>
Thu, 15 Jul 2021 13:06:22 +0000 (15:06 +0200)
committerMartin Mares <mj@ucw.cz>
Fri, 13 Aug 2021 11:05:48 +0000 (13:05 +0200)
teatimer.c

index 56d78c17543e9a549ebea043af3fda39434eeba9..1971d0d6d91104e30c1d76b94488d0e50e013829 100644 (file)
@@ -23,6 +23,7 @@ static char old_text[16];
 static GtkWidget *win, *hbox1, *vbox1, *timebox, *namebox, *togglebutton1;
 static time_t alarm_time;
 static char *run_cmd;
+static char *default_name = "Tea";
 static int expired;
 
 static void
@@ -195,7 +196,7 @@ open_window(void)
   namebox = gtk_entry_new_with_max_length(30);
   gtk_widget_show(namebox);
   gtk_box_pack_start(GTK_BOX(vbox1), namebox, TRUE, TRUE, 0);
-  gtk_entry_set_text(GTK_ENTRY(namebox), "Tea");
+  gtk_entry_set_text(GTK_ENTRY(namebox), default_name);
 
   timebox = gtk_entry_new_with_max_length(9);
   gtk_widget_show(timebox);
@@ -221,10 +222,11 @@ open_window(void)
   gtk_widget_show(win);
 }
 
-static const char short_opts[] = "r:";
+static const char short_opts[] = "r:n:";
 
 static const struct option long_opts[] = {
   { "run",             required_argument,      NULL,   'r' },
+  { "timer-name",      required_argument,      NULL,   'n' },
   { NULL,              0,                      NULL,   0   },
 };
 
@@ -236,6 +238,7 @@ Options:\n\
 -r, --run=<cmd>\t\tRun a given program when the tea is ready\n\
 \t\t\t\t%%d will be expanded to timer name\n\
 \t\t\t\t%%%% will be expanded to %%\n\
+-n, --timer-name=<str>\tFill name box with <str>\n\
 ");
   exit(1);
 }
@@ -253,6 +256,9 @@ main(int argc, char **argv)
       case 'r':
        run_cmd = optarg;
        break;
+      case 'n':
+       default_name = optarg;
+       break;
       default:
        usage();
       }