commit 61348ec062c6b94b2ea05b98aa609395d03072e3
Author: Mihir Lad <[email protected]>
Date: Sun Aug 23 23:12:27 2020 -0400
[dwm][patch][ipc] Update patch to v1.5.5
diff --git a/dwm.suckless.org/patches/ipc/dwm-ipc-20200729-f04cac6.diff
b/dwm.suckless.org/patches/ipc/dwm-ipc-20200824-f04cac6.diff
similarity index 99%
rename from dwm.suckless.org/patches/ipc/dwm-ipc-20200729-f04cac6.diff
rename to dwm.suckless.org/patches/ipc/dwm-ipc-20200824-f04cac6.diff
index 2ac88365..e98474d0 100644
--- a/dwm.suckless.org/patches/ipc/dwm-ipc-20200729-f04cac6.diff
+++ b/dwm.suckless.org/patches/ipc/dwm-ipc-20200824-f04cac6.diff
@@ -1,6 +1,6 @@
-From 1db4901625c20669b8e448b5c78b642fb792c844 Mon Sep 17 00:00:00 2001
+From 5ab24c98c2e884869977a1e67fe24cad30ab36cc Mon Sep 17 00:00:00 2001
From: mihirlad55 <[email protected]>
-Date: Wed, 29 Jul 2020 23:56:25 +0000
+Date: Mon, 24 Aug 2020 02:37:41 +0000
Subject: [PATCH] Add IPC support through a unix socket
This patch currently supports the following requests:
@@ -32,9 +32,9 @@ https://github.com/mihirlad55/dwm-ipc
IPCClient.c | 66 +++
IPCClient.h | 61 +++
Makefile | 10 +-
- config.def.h | 19 +
+ config.def.h | 18 +
config.mk | 8 +-
- dwm-msg.c | 543 +++++++++++++++++++++++
+ dwm-msg.c | 548 +++++++++++++++++++++++
dwm.c | 150 ++++++-
ipc.c | 1202 ++++++++++++++++++++++++++++++++++++++++++++++++++
ipc.h | 320 ++++++++++++++
@@ -42,7 +42,7 @@ https://github.com/mihirlad55/dwm-ipc
util.h | 10 +
yajl_dumps.c | 351 +++++++++++++++
yajl_dumps.h | 65 +++
- 13 files changed, 2927 insertions(+), 13 deletions(-)
+ 13 files changed, 2931 insertions(+), 13 deletions(-)
create mode 100644 IPCClient.c
create mode 100644 IPCClient.h
create mode 100644 dwm-msg.c
@@ -228,10 +228,10 @@ index 77bcbc0..0456754 100644
sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1
chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1
diff --git a/config.def.h b/config.def.h
-index 1c0b587..3ad9785 100644
+index 1c0b587..059a831 100644
--- a/config.def.h
+++ b/config.def.h
-@@ -113,3 +113,22 @@ static Button buttons[] = {
+@@ -113,3 +113,21 @@ static Button buttons[] = {
{ ClkTagBar, MODKEY, Button3, toggletag,
{0} },
};
@@ -245,7 +245,6 @@ index 1c0b587..3ad9785 100644
+ IPCCOMMAND( focusmon, 1, {ARG_TYPE_SINT} ),
+ IPCCOMMAND( focusstack, 1, {ARG_TYPE_SINT} ),
+ IPCCOMMAND( zoom, 1, {ARG_TYPE_NONE} ),
-+ IPCCOMMAND( spawn, 1, {ARG_TYPE_PTR} ),
+ IPCCOMMAND( incnmaster, 1, {ARG_TYPE_SINT} ),
+ IPCCOMMAND( killclient, 1, {ARG_TYPE_SINT} ),
+ IPCCOMMAND( togglefloating, 1, {ARG_TYPE_NONE} ),
@@ -276,10 +275,10 @@ index 7084c33..8570938 100644
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L
-DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
diff --git a/dwm-msg.c b/dwm-msg.c
new file mode 100644
-index 0000000..606f6ce
+index 0000000..0071781
--- /dev/null
+++ b/dwm-msg.c
-@@ -0,0 +1,543 @@
+@@ -0,0 +1,548 @@
+#include <ctype.h>
+#include <errno.h>
+#include <inttypes.h>
@@ -507,14 +506,19 @@ index 0000000..606f6ce
+{
+ size_t len = strlen(s);
+ int is_dot_used = 0;
++ int is_minus_used = 0;
+
+ // Floats can only have one decimal point in between or digits
++ // Optionally, floats can also be below zero (negative)
+ for (int i = 0; i < len; i++) {
+ if (isdigit(s[i]))
+ continue;
+ else if (!is_dot_used && s[i] == '.' && i != 0 && i != len - 1) {
+ is_dot_used = 1;
+ continue;
++ } else if (!is_minus_used && s[i] == '-' && i == 0) {
++ is_minus_used = 1;
++ continue;
+ } else
+ return 0;
+ }
@@ -3238,5 +3242,5 @@ index 0000000..ee9948e
+
+#endif // YAJL_DUMPS_H_
--
-2.27.0
+2.28.0
diff --git a/dwm.suckless.org/patches/ipc/dwm-ipc-v1.5.3-to-v1.5.4.diff
b/dwm.suckless.org/patches/ipc/dwm-ipc-v1.5.3-to-v1.5.4.diff
deleted file mode 100644
index dca3ca16..00000000
--- a/dwm.suckless.org/patches/ipc/dwm-ipc-v1.5.3-to-v1.5.4.diff
+++ /dev/null
@@ -1,203 +0,0 @@
-From 29ed50543dd31718fc55f9106dfc79aada72289d Mon Sep 17 00:00:00 2001
-From: mihirlad55 <[email protected]>
-Date: Wed, 29 Jul 2020 23:56:24 +0000
-Subject: [PATCH] Update from v1.5.3 to v1.5.4
-
-- Fix redirection of dwm-msg not working. This was caused by stdout never being
- flushed. stdout is now flushed after every event message is received.
-- Add --ignore-reply option to dwm-msg which ignores the initial
success/failure
- reply from the run_command and subscribe commands. This is most useful for
- subscribing to events and ignoring the initial success reply.
----
- dwm-msg.c | 120 ++++++++++++++++++++++++++++++++----------------------
- 1 file changed, 72 insertions(+), 48 deletions(-)
-
-diff --git a/dwm-msg.c b/dwm-msg.c
-index c957adf..606f6ce 100644
---- a/dwm-msg.c
-+++ b/dwm-msg.c
-@@ -46,6 +46,7 @@ typedef unsigned long Window;
-
- const char *DEFAULT_SOCKET_PATH = "/tmp/dwm.sock";
- static int sock_fd = -1;
-+static unsigned int ignore_reply = 0;
-
- typedef enum IPCMessageType {
- IPC_TYPE_RUN_COMMAND = 0,
-@@ -273,6 +274,18 @@ is_signed_int(const char *s)
- return 1;
- }
-
-+static void
-+flush_socket_reply()
-+{
-+ IPCMessageType reply_type;
-+ uint32_t reply_size;
-+ char *reply;
-+
-+ read_socket(&reply_type, &reply_size, &reply);
-+
-+ free(reply);
-+}
-+
- static void
- print_socket_reply()
- {
-@@ -283,6 +296,7 @@ print_socket_reply()
- read_socket(&reply_type, &reply_size, &reply);
-
- printf("%.*s
", reply_size, reply);
-+ fflush(stdout);
- free(reply);
- }
-
-@@ -322,7 +336,10 @@ run_command(const char *name, char *args[], int argc)
-
- send_message(IPC_TYPE_RUN_COMMAND, msg_size, (uint8_t *)msg);
-
-- print_socket_reply();
-+ if (!ignore_reply)
-+ print_socket_reply();
-+ else
-+ flush_socket_reply();
-
- yajl_gen_free(gen);
-
-@@ -408,7 +425,10 @@ subscribe(const char *event)
-
- send_message(IPC_TYPE_SUBSCRIBE, msg_size, (uint8_t *)msg);
-
-- print_socket_reply();
-+ if (!ignore_reply)
-+ print_socket_reply();
-+ else
-+ flush_socket_reply();
-
- yajl_gen_free(gen);
-
-@@ -433,7 +453,7 @@ usage_error(const char *prog_name, const char *format, ...)
- static void
- print_usage(const char *name)
- {
-- printf("usage: %s <command> [...]
", name);
-+ printf("usage: %s [options] <command> [...]
", name);
- puts("");
- puts("Commands:");
- puts(" run_command <name> [args...] Run an IPC command");
-@@ -456,14 +476,16 @@ print_usage(const char *name)
- puts("");
- puts(" help Display this message");
- puts("");
-+ puts("Options:");
-+ puts(" --ignore-reply Don't print reply messages from");
-+ puts(" run_command and subscribe.");
-+ puts("");
- }
-
- int
- main(int argc, char *argv[])
- {
- const char *prog_name = argv[0];
-- // Need at least command argument
-- if (argc < 2) usage_error(prog_name, "Expected an argument, got none");
-
- connect_to_socket();
- if (sock_fd == -1) {
-@@ -471,49 +493,51 @@ main(int argc, char *argv[])
- return 1;
- }
-
-- for (int i = 1; i < argc; i++) {
-- if (strcmp(argv[i], "help") == 0) {
-- print_usage(prog_name);
-- return 0;
-- } else if (strcmp(argv[i], "run_command") == 0) {
-- if (++i >= argc) usage_error(prog_name, "No command specified");
-- // Command name
-- char *command = argv[i];
-- // Command arguments are everything after command name
-- char **command_args = argv + ++i;
-- // Number of command arguments
-- int command_argc = argc - i;
-- run_command(command, command_args, command_argc);
-- return 0;
-- } else if (strcmp(argv[i], "get_monitors") == 0) {
-- get_monitors();
-- return 0;
-- } else if (strcmp(argv[i], "get_tags") == 0) {
-- get_tags();
-- return 0;
-- } else if (strcmp(argv[i], "get_layouts") == 0) {
-- get_layouts();
-- return 0;
-- } else if (strcmp(argv[i], "get_dwm_client") == 0) {
-- if (++i < argc) {
-- if (is_unsigned_int(argv[i])) {
-- Window win = atol(argv[i]);
-- get_dwm_client(win);
-- } else
-- usage_error(prog_name, "Expected unsigned integer argument");
-- } else
-- usage_error(prog_name, "Expected the window id");
-- return 0;
-- } else if (strcmp(argv[i], "subscribe") == 0) {
-- if (++i < argc) {
-- for (int j = i; j < argc; j++) subscribe(argv[j]);
-+ int i = 1;
-+ if (strcmp(argv[i], "--ignore-reply") == 0) {
-+ ignore_reply = 1;
-+ i++;
-+ }
-+
-+ if (i >= argc) usage_error(prog_name, "Expected an argument, got none");
-+
-+ if (strcmp(argv[i], "help") == 0)
-+ print_usage(prog_name);
-+ else if (strcmp(argv[i], "run_command") == 0) {
-+ if (++i >= argc) usage_error(prog_name, "No command specified");
-+ // Command name
-+ char *command = argv[i];
-+ // Command arguments are everything after command name
-+ char **command_args = argv + ++i;
-+ // Number of command arguments
-+ int command_argc = argc - i;
-+ run_command(command, command_args, command_argc);
-+ } else if (strcmp(argv[i], "get_monitors") == 0) {
-+ get_monitors();
-+ } else if (strcmp(argv[i], "get_tags") == 0) {
-+ get_tags();
-+ } else if (strcmp(argv[i], "get_layouts") == 0) {
-+ get_layouts();
-+ } else if (strcmp(argv[i], "get_dwm_client") == 0) {
-+ if (++i < argc) {
-+ if (is_unsigned_int(argv[i])) {
-+ Window win = atol(argv[i]);
-+ get_dwm_client(win);
- } else
-- usage_error(prog_name, "Expected event name");
-- // Keep listening for events forever
-- while (1) {
-- print_socket_reply();
-- }
-+ usage_error(prog_name, "Expected unsigned integer argument");
- } else
-- usage_error(prog_name, "Invalid argument '%s'", argv[i]);
-- }
-+ usage_error(prog_name, "Expected the window id");
-+ } else if (strcmp(argv[i], "subscribe") == 0) {
-+ if (++i < argc) {
-+ for (int j = i; j < argc; j++) subscribe(argv[j]);
-+ } else
-+ usage_error(prog_name, "Expected event name");
-+ // Keep listening for events forever
-+ while (1) {
-+ print_socket_reply();
-+ }
-+ } else
-+ usage_error(prog_name, "Invalid argument '%s'", argv[i]);
-+
-+ return 0;
- }
---
-2.27.0
-
diff --git a/dwm.suckless.org/patches/ipc/dwm-ipc-v1.5.4-to-v1.5.5.diff
b/dwm.suckless.org/patches/ipc/dwm-ipc-v1.5.4-to-v1.5.5.diff
new file mode 100644
index 00000000..0c628b3e
--- /dev/null
+++ b/dwm.suckless.org/patches/ipc/dwm-ipc-v1.5.4-to-v1.5.5.diff
@@ -0,0 +1,52 @@
+From dddee33beee02e4b71aa1a3e6c7df43c7f6376a8 Mon Sep 17 00:00:00 2001
+From: mihirlad55 <[email protected]>
+Date: Mon, 24 Aug 2020 02:37:40 +0000
+Subject: [PATCH] Update from v1.5.4 to v1.5.5
+
+- Fixed dwm-msg not accepting negative float values
+- Removed spawn command from config.def.h since it is currently unusuable and
+ does not provide any useful functionality
+---
+ config.def.h | 1 -
+ dwm-msg.c | 5 +++++
+ 2 files changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/config.def.h b/config.def.h
+index 3ad9785..059a831 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -123,7 +123,6 @@ static IPCCommand ipccommands[] = {
+ IPCCOMMAND( focusmon, 1, {ARG_TYPE_SINT} ),
+ IPCCOMMAND( focusstack, 1, {ARG_TYPE_SINT} ),
+ IPCCOMMAND( zoom, 1, {ARG_TYPE_NONE} ),
+- IPCCOMMAND( spawn, 1, {ARG_TYPE_PTR} ),
+ IPCCOMMAND( incnmaster, 1, {ARG_TYPE_SINT} ),
+ IPCCOMMAND( killclient, 1, {ARG_TYPE_SINT} ),
+ IPCCOMMAND( togglefloating, 1, {ARG_TYPE_NONE} ),
+diff --git a/dwm-msg.c b/dwm-msg.c
+index 606f6ce..0071781 100644
+--- a/dwm-msg.c
++++ b/dwm-msg.c
+@@ -225,14 +225,19 @@ is_float(const char *s)
+ {
+ size_t len = strlen(s);
+ int is_dot_used = 0;
++ int is_minus_used = 0;
+
+ // Floats can only have one decimal point in between or digits
++ // Optionally, floats can also be below zero (negative)
+ for (int i = 0; i < len; i++) {
+ if (isdigit(s[i]))
+ continue;
+ else if (!is_dot_used && s[i] == '.' && i != 0 && i != len - 1) {
+ is_dot_used = 1;
+ continue;
++ } else if (!is_minus_used && s[i] == '-' && i == 0) {
++ is_minus_used = 1;
++ continue;
+ } else
+ return 0;
+ }
+--
+2.28.0
+
diff --git a/dwm.suckless.org/patches/ipc/index.md
b/dwm.suckless.org/patches/ipc/index.md
index 7275ab77..27bde44b 100644
--- a/dwm.suckless.org/patches/ipc/index.md
+++ b/dwm.suckless.org/patches/ipc/index.md
@@ -64,10 +64,10 @@ creating custom shell scripts to control dwm.
Download
--------
-* IPC Patch v1.5.4:
- [dwm-ipc-20200729-f04cac6.diff](dwm-ipc-20200729-f04cac6.diff)
-* IPC Patch v1.5.3 to v1.5.4 Update:
- [dwm-ipc-v1.5.3-to-v1.5.4.diff](dwm-ipc-v1.5.3-to-v1.5.4.diff)
+* IPC Patch v1.5.5:
+ [dwm-ipc-20200824-f04cac6.diff](dwm-ipc-20200824-f04cac6.diff)
+* IPC Patch v1.5.4 to v1.5.5 Update:
+ [dwm-ipc-v1.5.4-to-v1.5.5.diff](dwm-ipc-v1.5.4-to-v1.5.5.diff)
The latest releases of the patch will always be available first on the project
[Releases](https://github.com/mihirlad55/dwm-ipc/releases) page. There are also