Skip to content

Instantly share code, notes, and snippets.

@kmaglione
Created January 7, 2012 08:30
Show Gist options
  • Save kmaglione/1574201 to your computer and use it in GitHub Desktop.
Save kmaglione/1574201 to your computer and use it in GitHub Desktop.
var win;
util.yieldable(function () {
outer:
while (!win) {
let _NET_WM_NAME = atom("_NET_WM_NAME");
let UTF8_STRING = atom("UTF8_STRING");
let title = window.document.title, mytitle = "{dactyl-window:" + Date.now() + "}";;
try {
for (let i in util.range(1, 1000)) {
window.document.title = mytitle;
yield 5
let list = getProperty(scrn.root, atom("_NET_CLIENT_LIST"), atom("WINDOW"), 0, 1024).value;
for (let [i, xid] in iter(list)) {
let prop = getProperty(xid, _NET_WM_NAME, UTF8_STRING, 0, 1024);
try {
if (prop && prop.value.readString() === mytitle) {
win = xid;
break outer;
}
}
catch (e) {}
}
}
}
finally {
window.document.title = title;
}
yield 100;
}
ready();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment