84 lines
2.2 KiB
C
84 lines
2.2 KiB
C
/*
|
|
The GPLv3 License (GPLv3)
|
|
|
|
Copyright (c) 2022 Akos Horvath
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#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);
|
|
// }
|
|
}
|