Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

26
LINES

< > BotCompany Repo | #1019040 // linux_parse_wmctrl_lpG_output

JavaX fragment (include)

/*
The first column always contains the window identity as a hexadecimal integer.
The second column always contains the desktop number (a -1 is used to identify a sticky window).
If the -p option is specified the next column will contain the PID for the window as a decimal integer.
If the -G option is specified then four integer columns will follow: x-offset, y-offset, width and height.
The next column always contains the client machine name.
The remainder of the line contains the window title (possibly with multiple spaces in the title).
*/

static L<wmctrl_Entry> linux_parse_wmctrl_lpG_output(S output) {
  try {
    ret map_pcall(tlft(output), func(S s) -> wmctrl_Entry {
      L<IntRange> streaks = takeFirst(8, nonStreaks(f isSpace, characters(s)));
      LS l = intRangeSubstrings(s, streaks);
      ret nu(wmctrl_Entry,
        windowTitle := trimSubstring(s, last(streaks).end),
        windowIdentity := l.get(0),
        desktopNumber := parseInt(l.get(1)),
        pid := parseInt(l.get(2)),
        bounds := rect(parseInt(l.get(3)), parseInt(l.get(4)), parseInt(l.get(5)), parseInt(l.get(6))),
        machineName := l.get(7));
    });
  } on fail {
    printIndent("wmctrl> " , output);
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 12 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1019040
Snippet name: linux_parse_wmctrl_lpG_output
Eternal ID of this version: #1019040/7
Text MD5: 8f79924d3695b21a1cdfb921475a4507
Author: stefan
Category: javax / html
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-01-04 00:13:21
Source code size: 1238 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 273 / 322
Version history: 6 change(s)
Referenced in: [show references]