From 0dce4c8ae122267b466eec98626f5629a29447a4 Mon Sep 17 00:00:00 2001 From: BossCode45 Date: Tue, 26 Nov 2024 16:04:52 +1300 Subject: feat: Made it so that YATmsg can now take input from the args It will now send whatever is in the args to YATwm --- YATmsg/YATmsg.cpp | 20 +++++++++++++++++--- 1 file 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 #include +#include #include #include #include @@ -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); -- cgit v1.2.3