summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBossCode45 <human.cyborg42@gmail.com>2024-11-26 16:04:52 +1300
committerBossCode45 <human.cyborg42@gmail.com>2024-11-26 16:04:52 +1300
commit0dce4c8ae122267b466eec98626f5629a29447a4 (patch)
tree5e8e3fdc5995557e87b354f5cd0808d29e5938c2
parent72300460c1c1fa294cc4d1f1026d203a5adf4d28 (diff)
downloadYATwm-0dce4c8ae122267b466eec98626f5629a29447a4.tar.gz
YATwm-0dce4c8ae122267b466eec98626f5629a29447a4.zip
feat: Made it so that YATmsg can now take input from the args
It will now send whatever is in the args to YATwm
-rw-r--r--YATmsg/YATmsg.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/YATmsg/YATmsg.cpp b/YATmsg/YATmsg.cpp
index dbc09b9..7013861 100644
--- a/YATmsg/YATmsg.cpp
+++ b/YATmsg/YATmsg.cpp
@@ -1,6 +1,7 @@
#include <X11/X.h>
#include <X11/Xlib.h>
+#include <cstring>
#include <iostream>
#include <sys/socket.h>
#include <sys/un.h>
@@ -8,8 +9,13 @@
using std::cout, std::endl;
-int main()
+int main(int argc, const char** argv)
{
+ if(argc < 2)
+ {
+ cout << "Not enough args" << endl;
+ return 1;
+ }
Display* dpy = XOpenDisplay(nullptr);
Window root = Window(DefaultRootWindow(dpy));
Atom propName = XInternAtom(dpy, "YATWM_SOCKET_PATH", false);
@@ -43,8 +49,16 @@ int main()
XFree(sockPath);
return 1;
}
- const char* command = "echo Hello from YATmsg!!!";
- if(write(sockfd, command, 22) == -1)
+
+ std::string message;
+ for(int i = 1; i < argc; i++)
+ {
+ message += argv[i];
+ if(i != argc - 1)
+ message += " ";
+ }
+ cout << "Sending: " << message << endl;
+ if(write(sockfd, message.c_str(), message.length()) == -1)
{
cout << "Failed write" << endl;
XFree(sockPath);