Skip to content

Instantly share code, notes, and snippets.

@anthonyheckmann
Last active June 12, 2019 18:41
Show Gist options
  • Select an option

  • Save anthonyheckmann/617842b2fa6b5c4d59347b88e86a1ec4 to your computer and use it in GitHub Desktop.

Select an option

Save anthonyheckmann/617842b2fa6b5c4d59347b88e86a1ec4 to your computer and use it in GitHub Desktop.

Revisions

  1. anthonyheckmann revised this gist Jun 12, 2019. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions track.c
    Original file line number Diff line number Diff line change
    @@ -7,6 +7,8 @@ like `track >> window.log`
    #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);
  2. anthonyheckmann created this gist Jun 12, 2019.
    25 changes: 25 additions & 0 deletions track.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    /* 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>

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