1818static bool no_duplicates ;
1919static bool no_footer ;
2020static bool no_header ;
21+ static bool pipemenu ;
2122
2223static const struct option long_options [] = {
2324 {"bare" , no_argument , NULL , 'b' },
2425 {"help" , no_argument , NULL , 'h' },
2526 {"no-duplicates" , no_argument , NULL , 'n' },
27+ {"pipemenu" , no_argument , NULL , 'p' },
2628 {0 , 0 , 0 , 0 }
2729};
2830
2931static const char labwc_menu_generator_usage [] =
3032"Usage: labwc-menu-generator [options...]\n"
3133" -b, --bare Show no header or footer\n"
3234" -h, --help Show help message and quit\n"
33- " -n, --no-duplicates Limit desktop entries to one directory only\n" ;
35+ " -n, --no-duplicates Limit desktop entries to one directory only\n"
36+ " -p, --pipemenu Output in pipemenu format\n" ;
3437
3538static void
3639usage (void )
@@ -144,9 +147,13 @@ print_menu(GList *dirs, GList *apps)
144147 GString * submenu = g_string_new (NULL );
145148
146149 if (!no_header ) {
147- printf ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" );
148- printf ("<openbox_menu>\n" );
149- printf ("<menu id=\"root-menu\" label=\"root-menu\">\n" );
150+ if (pipemenu ) {
151+ printf ("<openbox_pipe_menu>\n" );
152+ } else {
153+ printf ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" );
154+ printf ("<openbox_menu>\n" );
155+ printf ("<menu id=\"root-menu\" label=\"root-menu\">\n" );
156+ }
150157 }
151158
152159 /* Handle all directories except 'Other' */
@@ -186,8 +193,12 @@ print_menu(GList *dirs, GList *apps)
186193 }
187194
188195 if (!no_footer ) {
189- printf ("</menu> <!-- root-menu -->\n" );
190- printf ("</openbox_menu>\n" );
196+ if (pipemenu ) {
197+ printf ("</openbox_pipe_menu>\n" );
198+ } else {
199+ printf ("</menu> <!-- root-menu -->\n" );
200+ printf ("</openbox_menu>\n" );
201+ }
191202 }
192203
193204 g_string_free (submenu , TRUE);
@@ -273,7 +284,7 @@ main(int argc, char **argv)
273284 int c ;
274285 while (1 ) {
275286 int index = 0 ;
276- c = getopt_long (argc , argv , "bhn " , long_options , & index );
287+ c = getopt_long (argc , argv , "bhnp " , long_options , & index );
277288 if (c == -1 ) {
278289 break ;
279290 }
@@ -283,7 +294,10 @@ main(int argc, char **argv)
283294 no_header = true;
284295 break ;
285296 case 'n' :
286- no_duplicates = false;
297+ no_duplicates = true;
298+ break ;
299+ case 'p' :
300+ pipemenu = true;
287301 break ;
288302 case 'h' :
289303 default :
0 commit comments