.c.o:
@echo "CC $<"
- @$(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" -c -o $@ $<
+ @$(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" -D_POSIX_C_SOURCE="2" -c -o $@ $<
bspwm: $(WM_OBJ)
@echo CC -o $@
| | | | | |
+-------------------------+ +-------------------------+
+## Synopsis
+
+ bspwm [-v|-s STATUS_FIFO]
+
+ bspc MESSAGE [ARGUMENTS] [OPTIONS]
+
## Messages
The syntax for the client is `bspc MESSAGE [ARGUMENTS ...]`.
adaptative_raise
Prevent floating windows from being raised when they might cover other floating windows.
- status_stdout
- Output the status of monitors and desktops on stdout.
-
## Mouse Bindings
button_modifier + left mouse button
.SH NAME
bspwm \- Tiling window manager based on binary space partitioning
.SH SYNOPSIS
-.BI bspwm
-.RI [ -v ]
+.B bspwm
+.RI [ -v | "-s STATUS_FIFO" ]
.P
.BI bspc " MESSAGE"
.RI [ ARGUMENTS ]
.TP
.I adaptative_raise
Prevent floating windows from being raised when they might cover other floating windows.
-.TP
-.I status_stdout
-Output the status of monitors and desktops on stdout.
.SH MOUSE BINDINGS
.TP
.I button_modifier + left mouse button
int main(int argc, char *argv[])
{
- if (argc == 2 && strcmp(argv[1], "-v") == 0) {
- printf("%s\n", VERSION);
- exit(EXIT_SUCCESS);
- }
-
fd_set descriptors;
char socket_path[MAXLEN];
+ char *fifo_path = NULL;
int sock_fd, ret_fd, dpy_fd, sel, n;
struct sockaddr_un sock_address;
size_t rsplen = 0;
char msg[BUFSIZ] = {0};
char rsp[BUFSIZ] = {0};
-
xcb_generic_event_t *event;
+ char opt;
+
+ while ((opt = getopt(argc, argv, "vs:")) != -1) {
+ switch (opt) {
+ case 'v':
+ printf("%s\n", VERSION);
+ exit(EXIT_SUCCESS);
+ break;
+ case 's':
+ fifo_path = optarg;
+ break;
+ }
+ }
running = true;
-
dpy = xcb_connect(NULL, &default_screen);
if (xcb_connection_has_error(dpy))
bind(sock_fd, (struct sockaddr *) &sock_address, sizeof(sock_address));
listen(sock_fd, SOMAXCONN);
-
sel = MAX(sock_fd, dpy_fd) + 1;
+ if (fifo_path != NULL) {
+ int fifo_fd = open(fifo_path, O_RDWR | O_NONBLOCK);
+ if (fifo_fd != -1)
+ status_fifo = fdopen(fifo_fd, "w");
+ else
+ warn("couldn't open status fifo\n");
+ }
+
load_settings();
run_autostart();
grab_buttons();
}
close(sock_fd);
+ if (status_fifo != NULL)
+ fclose(status_fifo);
xcb_ewmh_connection_wipe(ewmh);
free(ewmh);
xcb_flush(dpy);
unsigned int client_uid;
xcb_screen_t *screen;
uint8_t root_depth;
+FILE *status_fifo;
split_mode_t split_mode;
direction_t split_dir;
void put_status(void)
{
- if (!status_stdout)
+ if (status_fifo == NULL)
return;
bool urgent = false;
for (monitor_t *m = mon_head; m != NULL; m = m->next) {
- printf("%c%s:", (mon == m ? 'M' : 'm'), m->name);
+ fprintf(status_fifo, "%c%s:", (mon == m ? 'M' : 'm'), m->name);
for (desktop_t *d = m->desk_head; d != NULL; d = d->next, urgent = false) {
for (node_t *n = first_extrema(d->root); n != NULL && !urgent; n = next_leaf(n))
urgent |= n->client->urgent;
- printf("%c%c%s:", (m->desk == d ? 'D' : (d->root != NULL ? 'd' : '_')), (urgent ? '!' : '_'), d->name);
+ fprintf(status_fifo, "%c%c%s:", (m->desk == d ? 'D' : (d->root != NULL ? 'd' : '_')), (urgent ? '!' : '_'), d->name);
}
}
- printf("L%s:W%X\n", (mon->desk->layout == LAYOUT_TILED ? "tiled" : "monocle"), (mon->desk->focus == NULL ? 0 : mon->desk->focus->client->window));
- fflush(stdout);
+ fprintf(status_fifo, "L%s:W%X\n", (mon->desk->layout == LAYOUT_TILED ? "tiled" : "monocle"), (mon->desk->focus == NULL ? 0 : mon->desk->focus->client->window));
+ fflush(status_fifo);
}
void arrange(monitor_t *m, desktop_t *d)