commit 19fcff6

wf  ·  2026-06-03 15:36:20 +0000 UTC
parent db413b4
Make the panel compile and run
2 files changed,  +14, -10
+4, -2
 1@@ -6,9 +6,11 @@ An attempt at a module-based panel/bar for Wayland.
 2 Notes
 3 -----
 4 
 5-It doesn't compile because I was changing the prototypes for the strings and forgot to change the string ops accordingly.
 6+There is no notion of modules right now outside of the fact that they are parsed, e.g. the bar is (at the moment) useless.
 7 
 8-Plus the config parsing is disgustingly implemented, but there's no better way (not that I can immediately think of).
 9+The config parsing is disgustingly implemented, but there's no better way (not that I can immediately think of).
10+
11+Please do not use it.
12 
13 Dependencies
14 ------------
+10, -8
 1@@ -218,8 +218,7 @@ parse_config(const char *path, struct app *app) {
 2 					if (s.params_len != 1) {
 3 						ERRNUM(s);
 4 					}
 5-					*app->config.style.font = '\0';
 6-					strncat(app->config.style.font, s.params[0], sizeof(app->config.style.font) - 1);
 7+					app->config.style.font = strdup(s.params[0]);
 8 				}
 9 			}
10 		}
11@@ -230,8 +229,7 @@ parse_config(const char *path, struct app *app) {
12 			}
13 			struct module m = {0};
14 			memset(&m, 0, sizeof(m));
15-			*m.name = '\0';
16-			strncat(m.name, d.params[0], sizeof(m.name) - 1);
17+			m.name = strdup(d.params[0]);
18 
19 			struct scfg_block sub = d.children;
20 			for (size_t j = 0; j < sub.directives_len; j++) {
21@@ -241,8 +239,7 @@ parse_config(const char *path, struct app *app) {
22 					if (s.params_len != 1) {
23 						ERRNUM(s);
24 					}
25-					*m.command = '\0';
26-					strncat(m.command, s.params[0], sizeof(m.command) - 1);
27+					m.command = strdup(s.params[0]);
28 				}
29 
30 				else if (strcmp(s.name, "interval") == 0) {
31@@ -292,8 +289,7 @@ parse_config(const char *path, struct app *app) {
32 							if (t.params_len != 1) {
33 								ERRNUM(t);
34 							}
35-							*m.style.font = '\0';
36-							strncat(m.style.font, t.params[0], sizeof(m.style.font) - 1);
37+							m.style.font = strdup(t.params[0]);
38 						}
39 
40 						else if (strcmp(t.name, "border-width") == 0) {
41@@ -312,6 +308,10 @@ parse_config(const char *path, struct app *app) {
42 					}
43 				}
44 			}
45+			LOG("parsed module `%s` with command `%s`\n", m.name, m.command);
46+			free(m.name);
47+			free(m.command);
48+			free(m.style.font);
49 		}
50 
51 		else if (strcmp(d.name, "modules-left") == 0 || strcmp(d.name, "modules-middle") == 0 || strcmp(d.name, "modules-right") == 0) {
52@@ -487,6 +487,8 @@ setup(struct app *app) {
53 
54 static void
55 cleanup(struct app *app) {
56+	if (app->config.style.font)
57+		free(app->config.style.font);
58 	if (app->wld_surface)
59 		wld_destroy_surface(app->wld_surface);
60 	if (app->wld_font)