forked from salman-abedin/devour
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevour.c
More file actions
42 lines (35 loc) · 708 Bytes
/
devour.c
File metadata and controls
42 lines (35 loc) · 708 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* devour
* X11 window swallower
*/
#include <X11/Xlib.h>
#include <stdlib.h>
#include <string.h>
#define UNSAFE_CHARS "`\"'()[]& "
void run_command(char **argv) {
char arg_char;
char *arg;
char cmd[1024] = {0};
while ((arg = *++argv)) {
while ((arg_char = *arg++)) {
if (strchr(UNSAFE_CHARS, arg_char))
strcat(cmd, "\\");
strncat(cmd, &arg_char, 1);
}
strcat(cmd, " ");
}
system(cmd);
}
int main(int argc, char **argv) {
int rev;
Window win;
Display *dis = XOpenDisplay(0);
XGetInputFocus(dis, &win, &rev);
XUnmapWindow(dis, win);
XFlush(dis);
run_command(argv);
XMapWindow(dis, win);
XCloseDisplay(dis);
(void)argc;
return 0;
}