Skip to content

Commit ec1ed31

Browse files
committed
Add -d|--desktop option
...to show filename in the XML output. When reading the output this changes makes it easier to understand which .desktop file is associated with each entry.
1 parent 85a014d commit ec1ed31

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

main.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ static bool no_duplicates;
2020
static bool no_footer;
2121
static bool no_header;
2222
static bool pipemenu;
23+
static bool show_desktop_filename;
2324

2425
static const struct option long_options[] = {
2526
{"bare", no_argument, NULL, 'b'},
27+
{"desktop", no_argument, NULL, 'd'},
2628
{"help", no_argument, NULL, 'h'},
2729
{"ignore", required_argument, NULL, 'i'},
2830
{"no-duplicates", no_argument, NULL, 'n'},
@@ -33,6 +35,7 @@ static const struct option long_options[] = {
3335
static const char labwc_menu_generator_usage[] =
3436
"Usage: labwc-menu-generator [options...]\n"
3537
" -b, --bare Show no header or footer\n"
38+
" -d, --desktop Add .desktop filename as a comment in the XML output\n"
3639
" -h, --help Show help message and quit\n"
3740
" -i, --ignore <file> Specify file listing .desktop files to ignore\n"
3841
" -n, --no-duplicates Limit desktop entries to one directory only\n"
@@ -62,6 +65,10 @@ ismatch(gchar **dir_categories, const char *app_categories)
6265
static void
6366
print_app_to_buffer(struct app *app, GString *submenu)
6467
{
68+
if (show_desktop_filename) {
69+
g_string_append_printf(submenu, " <!-- %s -->\n", app->filename);
70+
}
71+
6572
/* TODO: handle app->terminal */
6673
g_string_append_printf(submenu,
6774
" <item label=\"%s\" icon=\"%s\">\n",
@@ -287,7 +294,7 @@ main(int argc, char **argv)
287294
int c;
288295
while (1) {
289296
int index = 0;
290-
c = getopt_long(argc, argv, "bhi:np", long_options, &index);
297+
c = getopt_long(argc, argv, "bdhi:np", long_options, &index);
291298
if (c == -1) {
292299
break;
293300
}
@@ -296,6 +303,9 @@ main(int argc, char **argv)
296303
no_footer = true;
297304
no_header = true;
298305
break;
306+
case 'd':
307+
show_desktop_filename = true;
308+
break;
299309
case 'i':
300310
ignore_init(optarg);
301311
break;

0 commit comments

Comments
 (0)