mirror of
https://github.com/kolunmi/dwlb.git
synced 2025-12-16 11:03:17 +00:00
Compare commits
5 Commits
d1223810b2
...
337e53882f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
337e53882f | ||
|
|
1149930689 | ||
|
|
bdfee2104f | ||
|
|
e0bf2d0483 | ||
|
|
641899d473 |
38
dwlb.c
38
dwlb.c
@ -111,8 +111,7 @@
|
|||||||
" -set-top [OUTPUT] draw bar at the top\n" \
|
" -set-top [OUTPUT] draw bar at the top\n" \
|
||||||
" -set-bottom [OUTPUT] draw bar at the bottom\n" \
|
" -set-bottom [OUTPUT] draw bar at the bottom\n" \
|
||||||
" -toggle-location [OUTPUT] toggle bar location\n" \
|
" -toggle-location [OUTPUT] toggle bar location\n" \
|
||||||
" -printfocused [OUTPUT] print the title of focused window\n" \
|
" -printinfo [OUTPUT] print the title of focused window\n" \
|
||||||
" -printtags [OUTPUT] print the decimal representation of occupied tags\n" \
|
|
||||||
"Other\n" \
|
"Other\n" \
|
||||||
" -v get version information\n" \
|
" -v get version information\n" \
|
||||||
" -h view this help text\n"
|
" -h view this help text\n"
|
||||||
@ -1549,17 +1548,11 @@ read_socket(void)
|
|||||||
if (!bar->hidden)
|
if (!bar->hidden)
|
||||||
hide_bar(bar);
|
hide_bar(bar);
|
||||||
}
|
}
|
||||||
} else if (!strcmp(wordbeg, "printfocused")) {
|
} else if (!strcmp(wordbeg, "printinfo")) {
|
||||||
const char *info = (bar->window_title && bar->window_title[0] != '\0') ? bar->window_title : "(none)";
|
const char *info = (bar->window_title && bar->window_title[0] != '\0') ? bar->window_title : "(none)";
|
||||||
if (send(cli_fd, info, strlen(info), 0) == -1) {
|
if (send(cli_fd, info, strlen(info), 0) == -1) {
|
||||||
perror("send");
|
perror("send");
|
||||||
}
|
}
|
||||||
} else if (!strcmp(wordbeg, "printtags")) {
|
|
||||||
char tag_str[12];
|
|
||||||
snprintf(tag_str, sizeof(tag_str), "%u", bar->ctags);
|
|
||||||
if (send(cli_fd, tag_str, strlen(tag_str), 0) == -1) {
|
|
||||||
perror("send");
|
|
||||||
}
|
|
||||||
} else if (!strcmp(wordbeg, "toggle-visibility")) {
|
} else if (!strcmp(wordbeg, "toggle-visibility")) {
|
||||||
if (all) {
|
if (all) {
|
||||||
wl_list_for_each(bar, &bar_list, link)
|
wl_list_for_each(bar, &bar_list, link)
|
||||||
@ -1756,9 +1749,9 @@ main(int argc, char **argv)
|
|||||||
DIE("Option -hide requires an argument");
|
DIE("Option -hide requires an argument");
|
||||||
client_send_command(&sock_address, argv[i], "hide", NULL, target_socket);
|
client_send_command(&sock_address, argv[i], "hide", NULL, target_socket);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (!strcmp(argv[i], "-printfocused")) {
|
} else if (!strcmp(argv[i], "-printinfo")) {
|
||||||
if (++i >= argc)
|
if (++i >= argc)
|
||||||
DIE("Option -printfocused requires an argument");
|
DIE("Option -printinfo requires an argument");
|
||||||
int sockfd;
|
int sockfd;
|
||||||
if ((sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
|
if ((sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
|
||||||
EDIE("socket");
|
EDIE("socket");
|
||||||
@ -1766,28 +1759,7 @@ main(int argc, char **argv)
|
|||||||
if (connect(sockfd, (struct sockaddr *)&sock_address, sizeof(sock_address)) == -1)
|
if (connect(sockfd, (struct sockaddr *)&sock_address, sizeof(sock_address)) == -1)
|
||||||
EDIE("connect");
|
EDIE("connect");
|
||||||
char cmd[256];
|
char cmd[256];
|
||||||
snprintf(cmd, sizeof(cmd), "%s printfocused", argv[i]);
|
snprintf(cmd, sizeof(cmd), "%s printinfo", argv[i]);
|
||||||
if (send(sockfd, cmd, strlen(cmd), 0) == -1)
|
|
||||||
EDIE("send");
|
|
||||||
char buf[1024];
|
|
||||||
ssize_t len = recv(sockfd, buf, sizeof(buf) - 1, 0);
|
|
||||||
if (len > 0) {
|
|
||||||
buf[len] = '\0';
|
|
||||||
printf("%s\n", buf);
|
|
||||||
}
|
|
||||||
close(sockfd);
|
|
||||||
return 0;
|
|
||||||
} else if (!strcmp(argv[i], "-printtags")) {
|
|
||||||
if (++i >= argc)
|
|
||||||
DIE("Option -printtags requires an argument");
|
|
||||||
int sockfd;
|
|
||||||
if ((sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
|
|
||||||
EDIE("socket");
|
|
||||||
snprintf(sock_address.sun_path, sizeof(sock_address.sun_path), "%s/%s", socketdir, target_socket ? target_socket : "dwlb-0");
|
|
||||||
if (connect(sockfd, (struct sockaddr *)&sock_address, sizeof(sock_address)) == -1)
|
|
||||||
EDIE("connect");
|
|
||||||
char cmd[256];
|
|
||||||
snprintf(cmd, sizeof(cmd), "%s printtags", argv[i]);
|
|
||||||
if (send(sockfd, cmd, strlen(cmd), 0) == -1)
|
if (send(sockfd, cmd, strlen(cmd), 0) == -1)
|
||||||
EDIE("send");
|
EDIE("send");
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user