commit 588bd94
wf
·
2026-04-06 09:27:20 +0000 UTC
parent 60319bd
Add some command line flags
7 files changed,
+111,
-41
M
Makefile
+2,
-0
1@@ -32,11 +32,13 @@ $(howlc): $(howlc_src)
2 install: $(howl) $(howlc)
3 install -Dm755 $(howl) $(DESTDIR)$(PREFIX)/bin/$(howl)
4 install -Dm755 $(howlc) $(DESTDIR)$(PREFIX)/bin/$(howlc)
5+ install -Dm644 doc/howl.1 $(DESTDIR)$(PREFIX)/share/man/man1/howl.1
6 install -Dm644 doc/howlc.1 $(DESTDIR)$(PREFIX)/share/man/man1/howlc.1
7
8 uninstall:
9 rm -f $(DESTDIR)$(PREFIX)/bin/$(howl)
10 rm -f $(DESTDIR)$(PREFIX)/bin/$(howlc)
11+ rm -f $(DESTDIR)$(PREFIX)/share/man/man1/howl.1
12 rm -f $(DESTDIR)$(PREFIX)/share/man/man1/howlc.1
13
14 clean:
+1,
-2
1@@ -5,7 +5,7 @@ howl is a small wayland compositor written with the neuswc library.
2
3 It is controlled through an external client, which allows for scriptability.
4
5-See the `howlc` manual page for more information on usage.
6+See the `howl` and `howlc` manual pages for more information on usage.
7
8 TODO
9 ----
10@@ -13,7 +13,6 @@ TODO
11 * Expose compositor internals through the client
12 * Eyecandy: titlebars and double borders
13 * Clean up the codebase
14- * Flag for custom config path
15
16 CREDITS
17 -------
+23,
-0
1@@ -0,0 +1,23 @@
2+.\" generated with Ronn-NG/v0.10.1
3+.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
4+.TH "HOWL" "1" "April 2026" ""
5+.SH "NAME"
6+\fBhowl\fR \- small Wayland compositor
7+.SH "SYNOPSIS"
8+\fBhowl\fR [\-hv] [\-c \fIpath\fR]
9+.SH "DESCRIPTION"
10+\fBhowl\fR is a small Wayland compositor that is controlled externally by its client program howlc(1)\.
11+.SH "OPTIONS"
12+.TP
13+\fB\-h\fR
14+Print a help message describing the usage\.
15+.TP
16+\fB\-v\fR
17+Print the program version\.
18+.TP
19+\fB\-c\fR \fIpath\fR
20+Specify the path from which the config file will be loaded\.
21+.SH "COPYRIGHT"
22+\fBhowl\fR and \fBhowlc\fR are (C) wf 2026 \fIhttps://codeberg\.org/wf\fR\.
23+.SH "SEE ALSO"
24+README\.md, howlc(1)
+29,
-0
1@@ -0,0 +1,29 @@
2+howl(1) -- small Wayland compositor
3+===================================
4+
5+## SYNOPSIS
6+
7+`howl` [-hv] [-c <path>]
8+
9+## DESCRIPTION
10+
11+**howl** is a small Wayland compositor that is controlled externally by its client program howlc(1).
12+
13+## OPTIONS
14+
15+ * `-h`:
16+ Print a help message describing the usage.
17+
18+ * `-v`:
19+ Print the program version.
20+
21+ * `-c` <path>:
22+ Specify the path from which the config file will be loaded.
23+
24+## COPYRIGHT
25+
26+`howl` and `howlc` are (C) wf 2026 <https://codeberg.org/wf>.
27+
28+## SEE ALSO
29+
30+README.md, howlc(1)
+2,
-2
1@@ -6,7 +6,7 @@
2 .SH "SYNOPSIS"
3 \fBhowlc\fR \fIcmd\fR [\fIargs\fR\|\.\|\.\|\.]
4 .SH "DESCRIPTION"
5-\fBhowlc\fR is a client that controls the \fBhowl\fR compositor\.
6+\fBhowlc\fR is a client that controls the howl(1) compositor\.
7 .SH "COMMANDS"
8 .TP
9 \fBmove\fR, \fBmove_absolute\fR
10@@ -214,4 +214,4 @@ There is no way to unbind keys\. This is an swc problem, but still deserves to b
11 .SH "COPYRIGHT"
12 \fBhowl\fR and \fBhowlc\fR are (C) wf 2026 \fIhttps://codeberg\.org/wf\fR\.
13 .SH "SEE ALSO"
14-README\.md
15+README\.md, howl(1)
+2,
-2
1@@ -7,7 +7,7 @@ howlc(1) -- client to control the howl compositor
2
3 ## DESCRIPTION
4
5-**howlc** is a client that controls the `howl` compositor.
6+**howlc** is a client that controls the howl(1) compositor.
7
8 ## COMMANDS
9
10@@ -202,4 +202,4 @@ There is no way to unbind keys. This is an swc problem, but still deserves to be
11
12 ## SEE ALSO
13
14-README.md
15+README.md, howl(1)
M
howl.c
+52,
-35
1@@ -4,6 +4,7 @@
2 #include <errno.h>
3 #include <signal.h>
4 #include <unistd.h>
5+#include <getopt.h>
6 #include <sys/socket.h>
7 #include <sys/un.h>
8
9@@ -43,7 +44,6 @@ extern void ipc_bind(char **);
10 extern void ipc_quit(char **);
11 extern void ipc_config(char **);
12
13-bool have_config = true;
14 static struct wm wm;
15 static struct config config;
16
17@@ -249,40 +249,6 @@ setup(void) {
18
19 setup_ipc();
20
21- /* taken from berrywm, thanks! */
22- if (conf_path[0] == '\0') {
23- char *xdg_home = getenv("XDG_CONFIG_HOME");
24- if (xdg_home != NULL) {
25- snprintf(conf_path, MAXSIZE * sizeof(char), "%s/%s/%s", xdg_home, "howl", "autostart");
26- have_config = true;
27- } else {
28- char *home = getenv("HOME");
29- if (home == NULL) {
30- _wrn("couldn't find $HOME, autostart won't be loaded!");
31- have_config = false;
32- }
33- snprintf(conf_path, MAXSIZE * sizeof(char), "%s/%s/%s/%s", home, ".config", "howl", "autostart");
34- }
35- }
36-
37- if (have_config) load_config(conf_path);
38-
39- /* FIXME: these don't get enough time to inherit the modkey that the user configured */
40- swc_add_binding(
41- SWC_BINDING_BUTTON,
42- config.mod,
43- 0x110, /* left mouse button */
44- mouse_move,
45- NULL
46- );
47- swc_add_binding(
48- SWC_BINDING_BUTTON,
49- config.mod,
50- 0x111, /* right mouse button */
51- mouse_resize,
52- NULL
53- );
54-
55 signal(SIGINT, sig_handler);
56 signal(SIGTERM, sig_handler);
57 signal(SIGQUIT, sig_handler);
58@@ -537,7 +503,58 @@ on_scr_destroy(void *data) {
59
60 int
61 main(int argc, char **argv) {
62+ bool have_config;
63+ char *conf_path = malloc(MAXSIZE * sizeof(char));
64+ conf_path[0] = '\0';
65+
66+ int opt;
67+ while ((opt = getopt(argc, argv, ":hvc:")) != -1) {
68+ switch (opt) {
69+ case 'h':
70+ fprintf(stderr, "Usage: howl [-hv] [-c path]\n");
71+ return 0;
72+ break;
73+ case 'v':
74+ fprintf(stderr, "howl v%s\n", VERSION);
75+ return 0;
76+ break;
77+ case 'c':
78+ snprintf(conf_path, sizeof conf_path, "%s", optarg);
79+ break;
80+ case '?':
81+ fprintf(stderr, "Unknown option: -%c", optopt);
82+ return 1;
83+ break;
84+ case ':':
85+ fprintf(stderr, "Missing argument for option -%c", optopt);
86+ return 1;
87+ break;
88+ }
89+ }
90+
91 setup();
92+
93+ /* taken from berrywm, thanks! */
94+ if (conf_path[0] == '\0') {
95+ char *xdg_home = getenv("XDG_CONFIG_HOME");
96+ if (xdg_home != NULL) {
97+ snprintf(conf_path, MAXSIZE * sizeof(char), "%s/%s/%s", xdg_home, "howl", "autostart");
98+ have_config = true;
99+ } else {
100+ char *home = getenv("HOME");
101+ if (home == NULL) {
102+ _wrn("couldn't find $HOME, autostart won't be loaded!");
103+ have_config = false;
104+ }
105+ snprintf(conf_path, MAXSIZE * sizeof(char), "%s/%s/%s/%s", home, ".config", "howl", "autostart");
106+ }
107+ }
108+
109+ if (have_config) {
110+ signal(SIGCHLD, SIG_IGN);
111+ load_config(conf_path);
112+ }
113+
114 wl_display_run(wm.dpy);
115 cleanup();
116 return 1;