你也有C-tag,所以让我建议你自己去做xdpyinfo
。下面的C程序打印只是扩展:
#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static int compare(const void *a, const void *b)
{
return strcmp(*(char **) a, *(char **) b);
}
static void print_extension_info(Display * dpy)
{
int n = 0, i;
char **extlist = XListExtensions(dpy, &n);
printf("number of extensions: %d\n", n);
if (extlist) {
qsort(extlist, n, sizeof(char *), compare);
for (i = 0; i < n; i++) {
printf(" %s\n", extlist[i]);
}
}
// TODO: it might not be a good idea to free extlist, check
}
int main()
{
Display *dpy;
char *displayname = NULL;
dpy = XOpenDisplay(displayname);
if (!dpy) {
fprintf(stderr, "Unable to open display \"%s\".\n",
XDisplayName(displayname));
exit(EXIT_FAILURE);
}
print_extension_info(dpy);
XCloseDisplay(dpy);
exit(EXIT_SUCCESS);
}
编译如:GCC
gcc -O3 -g3 -W -Wall -Wextra xdpyinfo1.0.2.c $(pkg-config --cflags --libs x11) -o xdpyinfo1.0.2
(应该给出一个有关未使用的argc警告,但这是无害的)
只要改变printf()
的到你想要的格式。
非常感谢,这看起来让我获得了大部分途径,但是取消辛苦工作成为替代xdpyinfo的努力是件可耻的事情,但那仅仅是一些printfs。 – hildred
@hildred如果你做得太多,会让你感到头疼,如果你也做得太过分了...... *叹*这个小程序列出了扩展名。你想让我扩大它接受命令行的查询,或者你可以自己做吗? – deamentiaemundi
不,我的c没有那么糟糕,我可以从这里拿它,这是我生锈的X11的东西。我很快就会在github上发布它。你对gpl3许可证有什么看法? – hildred