summaryrefslogtreecommitdiff
path: root/YATmsg/YATmsg.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'YATmsg/YATmsg.cpp')
-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);