Uses 1113K of libraries. Click here for Pure Java version (9928L/54K).
1 | !7 |
2 | |
3 | cmodule2 LinuxWindowList > DynObjectTable<wmctrl_Entry> { |
4 | switchable bool inZOrder = false; |
5 | |
6 | start { |
7 | if (!isLinux()) |
8 | ret with setModuleName("Sorry, wrong OS - LINUX Window List"); |
9 | |
10 | dontPersist(); |
11 | set fieldsInOrder; |
12 | defaultAction = voidfunc(wmctrl_Entry e) { wmctrl_activateWindow(e) }; |
13 | doEvery(0.0, 10.0, r updateMe); |
14 | dm_vmBus_answerToMessage currentWindowTitle(() -> currentWindowTitle()); |
15 | } |
16 | |
17 | afterVisualize { |
18 | popupMenuItem_top("Close window", r { wmctrl_closeWindow(selected()) }); |
19 | popupMenuItem_top("Switch to window", defaultAction); |
20 | popupMenuItem_top("Shoot window", rThread { showImage(shootSystemWindow(selected())) }); |
21 | } |
22 | |
23 | void update { |
24 | S output = backtick("wmctrl -lpG"); |
25 | L<wmctrl_Entry> l = linux_parse_wmctrl_lpG_output(output); |
26 | if (inZOrder) { |
27 | LS order = map last7chars(regexpExtractAll("0x[a-f0-9]+", backtick("xprop -root _NET_CLIENT_LIST_STACKING"))); |
28 | final Map<S, Int> map = mapItemsToListIndex(order); |
29 | l = sortedByCalculatedFieldDesc(l, func(wmctrl_Entry e) { |
30 | map.get(last7chars(e.windowIdentity)) |
31 | }); |
32 | } |
33 | setData(l); |
34 | } |
35 | |
36 | // API |
37 | |
38 | // id = "0x..." |
39 | S titleForWindowID(S windowIdentity) { |
40 | while (l(windowIdentity) < 10) windowIdentity = spliceString(windowIdentity, 2, 2, "0"); |
41 | //print("Searching window: " + windowIdentity); |
42 | ret getString windowTitle(objectWhere(data(), +windowIdentity)); |
43 | } |
44 | |
45 | // may be costly (one invocation of xprop) |
46 | // information is accurate if window is older than 10 secs |
47 | S currentWindowTitle() enter { |
48 | ret titleForWindowID(linux_activeWindowID()); |
49 | } |
50 | } |
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: | 512 / 37757 |
Version history: | 40 change(s) |
Referenced in: | [show references] |