+/*
+ * i3bar - an xcb-based status- and ws-bar for i3
+ *
+ * © 2010 Axel Wagner and contributors
+ *
+ * See file LICNSE for license information
+ *
+ * src/child.c: Getting Input for the statusline
+ *
+ */
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
}
/*
- * Since we don't use colors and stuff, we strip the dzen-formatstrings
- *
- */
-void strip_dzen_formats(char *buffer) {
- char *src = buffer;
- char *dest = buffer;
- while (*src != '\0') {
- /* ^ starts a format-string, ) ends it */
- if (*src == '^') {
- /* We replace the seperators from i3status by pipe-symbols */
- if (!strncmp(src, "^ro", strlen("^ro"))) {
- *(dest++) = ' ';
- *(dest++) = '|';
- *(dest++) = ' ';
- }
- while (*src != ')') {
- src++;
- }
- src++;
- } else {
- *dest = *src;
- src++;
- dest++;
- }
- }
- /* The last character is \n, which xcb cannot display */
- *(--dest) = '\0';
-}
-
-/*
- * Callbalk for stdin. We read a line from stdin, strip dzen-formats and store
- * the result in statusline
+ * Callbalk for stdin. We read a line from stdin and store the result
+ * in statusline
*
*/
void stdin_io_cb(struct ev_loop *loop, ev_io *watcher, int revents) {
n = read(fd, buffer + rec, buffer_len - rec);
if (n == -1) {
if (errno == EAGAIN) {
+ /* remove trailing newline and finish up */
+ buffer[rec-1] = '\0';
break;
}
printf("ERROR: read() failed!");
buffer_len += STDIN_CHUNK_SIZE;
FREE(tmp);
} else {
+ /* remove trailing newline and finish up */
+ buffer[rec-1] = '\0';
break;
}
}
FREE(buffer);
return;
}
- strip_dzen_formats(buffer);
FREE(statusline);
statusline = buffer;
printf("%s\n", buffer);
}
/*
- * kill()s the child-prozess (if existend) and closes and
+ * kill()s the child-process (if existent) and closes and
* free()s the stdin- and sigchild-watchers
*
*/
}
cleanup();
}
+
+/*
+ * Sends a SIGSTOP to the child-process (if existent)
+ *
+ */
+void stop_child() {
+ if (child_pid != 0) {
+ kill(child_pid, SIGSTOP);
+ }
+}
+
+/*
+ * Sends a SIGCONT to the child-process (if existent)
+ *
+ */
+void cont_child() {
+ if (child_pid != 0) {
+ kill(child_pid, SIGCONT);
+ }
+}