Uses 1113K of libraries. Click here for Pure Java version (9928L/54K).
!7 cmodule2 LinuxWindowList > DynObjectTable<wmctrl_Entry> { switchable bool inZOrder = false; start { if (!isLinux()) ret with setModuleName("Sorry, wrong OS - LINUX Window List"); dontPersist(); set fieldsInOrder; defaultAction = voidfunc(wmctrl_Entry e) { wmctrl_activateWindow(e) }; doEvery(0.0, 10.0, r updateMe); dm_vmBus_answerToMessage currentWindowTitle(() -> currentWindowTitle()); } afterVisualize { popupMenuItem_top("Close window", r { wmctrl_closeWindow(selected()) }); popupMenuItem_top("Switch to window", defaultAction); popupMenuItem_top("Shoot window", rThread { showImage(shootSystemWindow(selected())) }); } void update { S output = backtick("wmctrl -lpG"); L<wmctrl_Entry> l = linux_parse_wmctrl_lpG_output(output); if (inZOrder) { LS order = map last7chars(regexpExtractAll("0x[a-f0-9]+", backtick("xprop -root _NET_CLIENT_LIST_STACKING"))); final Map<S, Int> map = mapItemsToListIndex(order); l = sortedByCalculatedFieldDesc(l, func(wmctrl_Entry e) { map.get(last7chars(e.windowIdentity)) }); } setData(l); } // API // id = "0x..." S titleForWindowID(S windowIdentity) { while (l(windowIdentity) < 10) windowIdentity = spliceString(windowIdentity, 2, 2, "0"); //print("Searching window: " + windowIdentity); ret getString windowTitle(objectWhere(data(), +windowIdentity)); } // may be costly (one invocation of xprop) // information is accurate if window is older than 10 secs S currentWindowTitle() enter { ret titleForWindowID(linux_activeWindowID()); } }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1019034 |
Snippet name: | Host Window List [for Linux, using wmctrl] |
Eternal ID of this version: | #1019034/41 |
Text MD5: | 0093e4bb924a39e4ec3294a4453a1d5b |
Transpilation MD5: | 0c0923e8f6e9d6730e38ef2aa2a0281a |
Author: | stefan |
Category: | javax / html |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-06-29 08:06:17 |
Source code size: | 1696 bytes / 50 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 509 / 37753 |
Version history: | 40 change(s) |
Referenced in: | #1020497 - dm_requireLinuxWindowList #1020498 - dm_linuxWindowList (if loaded) |