Last active
June 12, 2019 18:41
-
-
Save anthonyheckmann/617842b2fa6b5c4d59347b88e86a1ec4 to your computer and use it in GitHub Desktop.
simple X window tracker application
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Found here https://bbs.archlinux.org/viewtopic.php?pid=1551884#p1551884 | |
| By user Trilby | |
| Compile with `gcc -o track track.c -lX11`, and consider putting into .xinitrc | |
| like `track >> window.log` | |
| */ | |
| #include <stdio.h> | |
| #include <time.h> | |
| #include <X11/Xlib.h> | |
| /*This grabs XEvents, gets the window title and prints it with timestamp*/ | |
| int main() { | |
| Display *dpy = XOpenDisplay(0x0); | |
| XSelectInput(dpy, DefaultRootWindow(dpy), FocusChangeMask); | |
| Window win; | |
| int ignore; | |
| char *title; | |
| XEvent ev; | |
| while (!XNextEvent(dpy,&ev)) { | |
| XGetInputFocus(dpy, &win, &ignore); | |
| if (XFetchName(dpy, win, &title)) { | |
| printf("%d\t%s\n", time(NULL), title); | |
| XFree(title); | |
| } | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment