繁体   English   中英

如何使用c中的路径更改xeyes的颜色?

[英]how to change color of xeyes using a path in c?

这一切在Linux中不是Windows

你好,我想知道我如何像在终端一样改变xeyes的颜色

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
}

如果我只是简单地调用/ usr / bin / X11 / xeyes,它只会显示眼睛

现在我正在尝试添加/ usr / bin / X11 / xeyes-fg之类的命令,但是它不起作用

有什么建议吗?

您可以添加到参数向量,如下所示:

#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
}

这是结果的图片: xeyes-蓝点

副手,我希望strace显示正在打开的文件rgb.txt,但不会使用-f选项看到此情况(假定它发生在服务器中)。 “蓝色”确实显示在跟踪中,但仅显示在exec调用中,例如,

execve("/usr/bin/X11/xeyes", ["/usr/bin/X11/xeyes", "-fg", "blue"], [/* 62 vars */]) = 0

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM