65 lines
1.6 KiB
C
65 lines
1.6 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <sys/socket.h>
|
|
#include <sys/un.h>
|
|
#include <xcb/xcb.h>
|
|
int main(int argc, char **argv)
|
|
{
|
|
int wm_socket_fd;
|
|
struct sockaddr_un sock_addr;
|
|
char *c;
|
|
char buf[100];
|
|
int ret, d, s;
|
|
|
|
if (argc < 2) {
|
|
fprintf(stderr, "No arguments\n");
|
|
exit(1);
|
|
}
|
|
|
|
|
|
ret = xcb_parse_display(NULL, &c, &d, &s);
|
|
|
|
if (ret == -1) {
|
|
fprintf(stderr, "wmc: could not parse display. Exiting.\n");
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
ret = wm_socket_fd = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0);
|
|
|
|
if (ret == -1) {
|
|
fprintf(stderr, "wmc: could not create socket. Exiting.\n");
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
sock_addr.sun_family = AF_UNIX;
|
|
|
|
snprintf(sock_addr.sun_path, sizeof(sock_addr.sun_path),
|
|
"/tmp/wm_socket_1");
|
|
printf("display: %d\n", d);
|
|
|
|
ret = connect(wm_socket_fd, (struct sockaddr *) &sock_addr, sizeof(sock_addr));
|
|
|
|
if (ret == -1) {
|
|
fprintf(stderr, "wmc: could not connect to socket. Exiting.\n");
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
strncpy(buf, "set window-width 2", 100);
|
|
//char *buf = "set window-width 2";
|
|
ret = send(wm_socket_fd, buf, 100, 0);
|
|
|
|
if (ret == -1) {
|
|
fprintf(stderr, "wmc: could not send data to socket. Exiting.\n");
|
|
exit(EXIT_FAILURE);
|
|
} else {
|
|
printf("wmc: sent %d bytes\n", ret);
|
|
}
|
|
// ret = listen(wm_socket_fd, 512);
|
|
|
|
// if (ret == -1) {
|
|
// fprintf(stderr, "wm: could not listen to socket. Exiting.\n");
|
|
// exit(EXIT_FAILURE);
|
|
// }
|
|
}
|