[英]how to change color of xeyes using a path in c?
all this in Linux not windows 这一切在Linux中不是Windows
hello i want to know how i can change the color of xeyes like we can do in terminal like 你好,我想知道我如何像在终端一样改变xeyes的颜色
xeyes -fg blue now i want to to do this in c program using path xeyes -fg blue现在我想使用路径在C程序中执行此操作
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <string.h>
#include <malloc.h>
//#inlcude <windows.h>
#define LB_SIZE 1024
int main(int argc, char *argv[])
{
char fullPathName[] = "/usr/bin/X11/xeyes";
char *myArgv[LB_SIZE]; // an array of pointers
myArgv[0] = (char *) malloc(strlen(fullPathName) + 1);
strcpy(myArgv[0], fullPathName);
myArgv[1] = NULL; // last element should be a NULL pointer
execvp(fullPathName, myArgv);
exit(0); // should not be reached
}
if i simply call /usr/bin/X11/xeyes it just show eyes 如果我只是简单地调用/ usr / bin / X11 / xeyes,它只会显示眼睛
now i am trying to add command like /usr/bin/X11/xeyes-fg but its not working 现在我正在尝试添加/ usr / bin / X11 / xeyes-fg之类的命令,但是它不起作用
any suggestion? 有什么建议吗?
You can add onto the argument vector, like this: 您可以添加到参数向量,如下所示:
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <malloc.h>
#define LB_SIZE 1024
int main(int argc, char *argv[])
{
char fullPathName[] = "/usr/bin/X11/xeyes";
char *myArgv[LB_SIZE]; // an array of pointers
int n = 0;
myArgv[0] = (char *) malloc(strlen(fullPathName) + 1);
strcpy(myArgv[n++], fullPathName);
myArgv[n++] = "-fg";
myArgv[n++] = "blue";
myArgv[n] = NULL; // last element should be a NULL pointer
execvp(fullPathName, myArgv);
exit(0); // should not be reached
}
Here is a picture of the result: 这是结果的图片:
Offhand, I would have expected strace
to show the file rgb.txt being opened, but do not see this using -f
option (assume it happens in the server). 副手,我希望
strace
显示正在打开的文件rgb.txt,但不会使用-f
选项看到此情况(假定它发生在服务器中)。 The "blue" does show up in a trace, but only in the exec call, eg, “蓝色”确实显示在跟踪中,但仅显示在exec调用中,例如,
execve("/usr/bin/X11/xeyes", ["/usr/bin/X11/xeyes", "-fg", "blue"], [/* 62 vars */]) = 0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.