diff -ru ./ChangeLog ../wavbreaker-0.7-thp-patches/ChangeLog
--- ./ChangeLog	2006-02-20 06:21:35.000000000 +0100
+++ ../wavbreaker-0.7-thp-patches/ChangeLog	2006-07-19 20:33:50.000000000 +0200
@@ -1,3 +1,12 @@
+2006-07-19 20:33  Thomas Perl <thp@perli.net>
+
+	* src/wavbreaker.c: command line parameter handling
+
+2006-07-19 19:23  Thomas Perl <thp@perli.net>
+
+	* src/wavbreaker.c: Use proper format string in sprintf for track
+	  numbers when auto-generating file names
+
 2006-02-20 01:25  Timothy Robinson <tdrobinson@huli.org>
 
 	* configure.in, src/alsaaudio.c, src/appconfig.c: bumped version to
diff -ru ./src/wavbreaker.c ../wavbreaker-0.7-thp-patches/src/wavbreaker.c
--- ./src/wavbreaker.c	2006-02-26 16:37:27.000000000 +0100
+++ ../wavbreaker-0.7-thp-patches/src/wavbreaker.c	2006-07-19 20:55:07.000000000 +0200
@@ -134,6 +134,7 @@
 void filesel_cancel_clicked(GtkWidget *widget, gpointer data);
 void set_sample_filename(const char *f);
 static void open_file();
+static gboolean open_file_argv1( gpointer data);
 
 /* Sample and Summary Display Functions */
 static void redraw();
@@ -631,24 +632,12 @@
             track_num++;
         }
         prev_disc_num = disc_num;
-        if (index < 10) {
-            sprintf(buf, "d%dt0%d", disc_num, track_num);
-        } else {
-            sprintf(buf, "d%dt%d", disc_num, track_num);
-        }
+        sprintf(buf, "d%dt%02d", disc_num, track_num);
     } else {
-        if (index < 10) {
-            if (get_prepend_file_number()) {
-                sprintf(buf, "0%d%s", index, get_etree_filename_suffix());
-            } else {
-                sprintf(buf, "%s0%d", get_etree_filename_suffix(), index);
-            }
+        if (get_prepend_file_number()) {
+            sprintf(buf, "%02d%s", index, get_etree_filename_suffix());
         } else {
-            if (get_prepend_file_number()) {
-                sprintf(buf, "%d%s", index, get_etree_filename_suffix());
-            } else {
-                sprintf(buf, "%s%d", get_etree_filename_suffix(), index);
-            }
+            sprintf(buf, "%s%02d", get_etree_filename_suffix(), index);
         }
     }
 
@@ -1156,6 +1145,17 @@
     idle_func_num = gtk_idle_add(file_open_progress_idle_func, NULL);
 }
 
+static gboolean open_file_argv1( gpointer data) {
+    /* If we have a file to open as argv[1], open it here */
+    if( data != NULL) {
+      set_sample_filename( (char *)data);
+      open_file();
+    }
+
+    /* do not call this function again = return FALSE */
+    return FALSE;
+}
+
 void filesel_ok_clicked(GtkWidget *widget, gpointer user_data) {
     GtkWidget *filesel;
 
@@ -2041,6 +2041,10 @@
     GtkWidget *button_hbox;
     GtkWidget *label;
 
+    /* for parameter handling (auto-open) */
+    gpointer argv1_data;
+    struct stat argv1_stat;
+
     g_thread_init(NULL);
     gdk_threads_init();
     gtk_init(&argc, &argv);
@@ -2346,6 +2350,18 @@
     }
     gtk_widget_show(main_window);
 
+    /* handle command-line parameter, if there is one */
+    if( argc > 1) {
+      /* very primitive "file is okay?" checking here.. */
+      if( stat( argv[1], &argv1_stat) == 0) {
+        argv1_data = (gboolean)argv[1];
+        /* call as soon as possible in gtk main loop */
+        g_idle_add( open_file_argv1, argv1_data);
+      } else {
+        fprintf( stderr, "Cannot open file: %s\n", argv[1]);
+      }
+    }
+
     if (!g_thread_supported ()) g_thread_init (NULL);
     gdk_threads_enter();
     gtk_main();
