Skip to content

Commit 44205b9

Browse files
committed
Add -b option to prevent outputting header and footer
1 parent 23e8788 commit 44205b9

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
.POSIX:
44

55
RM ?= rm -f
6-
CFLAGS += -g -Wall -Os -std=c99 -Wextra
76
MAKEFLAGS += --no-print-directory
7+
CFLAGS += -g -Wall -Os -std=c99 -Wextra
88
CFLAGS += `pkg-config --cflags glib-2.0`
99
LIBS += `pkg-config --libs glib-2.0`
1010
LDFLAGS += $(LIBS)
@@ -22,8 +22,6 @@ all: $(PROG)
2222
$(PROG): main.o desktop.o
2323
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
2424

25-
%.o : src/%.c
26-
2725
clean:
2826
@$(RM) $(PROG) *.o
2927
@$(MAKE) -C t/ clean

main.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include "schema.h"
1717

1818
static bool no_duplicates;
19+
static bool no_footer;
20+
static bool no_header;
1921

2022
static const char labwc_menu_generator_usage[] =
2123
"Usage: labwc-menu-generator [options...]\n"
@@ -133,9 +135,11 @@ print_menu(GList *dirs, GList *apps)
133135
{
134136
GString *submenu = g_string_new(NULL);
135137

136-
printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
137-
printf("<openbox_menu>\n");
138-
printf("<menu id=\"root-menu\" label=\"root-menu\">\n");
138+
if (!no_header) {
139+
printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
140+
printf("<openbox_menu>\n");
141+
printf("<menu id=\"root-menu\" label=\"root-menu\">\n");
142+
}
139143

140144
/* Handle all directories except 'Other' */
141145
GList *iter;
@@ -173,8 +177,10 @@ print_menu(GList *dirs, GList *apps)
173177
printf("\t</menu> <!-- %s -->\n", dir->name);
174178
}
175179

176-
printf("</menu> <!-- root-menu -->\n");
177-
printf("</openbox_menu>\n");
180+
if (!no_footer) {
181+
printf("</menu> <!-- root-menu -->\n");
182+
printf("</openbox_menu>\n");
183+
}
178184

179185
g_string_free(submenu, TRUE);
180186
}
@@ -257,8 +263,12 @@ int
257263
main(int argc, char **argv)
258264
{
259265
int c;
260-
while ((c = getopt(argc, argv, "hn")) != -1) {
266+
while ((c = getopt(argc, argv, "bhn")) != -1) {
261267
switch (c) {
268+
case 'b':
269+
no_footer = true;
270+
no_header = true;
271+
break;
262272
case 'n':
263273
no_duplicates = false;
264274
break;

0 commit comments

Comments
 (0)