vimtk.xctrl module¶
- vimtk.xctrl.windows_in_order()[source]¶
CommandLine
python -m vimtk.xctrl windows_in_order
References
https://stackoverflow.com/questions/15638885/linux-how-to-get-a-list-of-all-visible-windows
Example
>>> # xdoctest: +REQUIRES(env:DISPLAY) >>> from vimtk.xctrl import * >>> result = list(windows_in_order()) >>> for win in result: ... if win.visible(): ... print(win)
- vimtk.xctrl.find_windows(proc=None, title=None, visible=True)[source]¶
CommandLine
python -m vimtk.xctrl find_windows
Example
>>> # xdoctest: +REQUIRES(env:DISPLAY) >>> from vimtk.xctrl import * # NOQA >>> for win in find_windows('gvim'): >>> print(ub.urepr(win.info())) >>> for win in find_windows('terminator'): >>> print(ub.urepr(win.info()))
- class vimtk.xctrl.XWindow(wm_id, info=None, sleeptime=0.01)[source]¶
Bases:
object
TODO: make API consistent with the win32 version
- classmethod current()[source]¶
CommandLine
VIMTK_TEST=1 xdoctest -m vimtk.xctrl XWindow.current
Example
>>> # xdoctest: +REQUIRES(env:VIMTK_TEST) >>> from vimtk.xctrl import * # NOQA >>> self = XWindow.current() >>> print('self: XWindow = {}'.format(ub.urepr(self, nl=1))) >>> print('info = ' + ub.urepr(self.wininfo()))
- property hexid¶
- resize(width, height)[source]¶
CommandLine
VIMTK_TEST=1 xdoctest -m vimtk.xctrl XWindow.resize
Example
>>> # xdoctest: +REQUIRES(env:VIMTK_TEST) >>> from vimtk.xctrl import * # NOQA >>> self = XWindow.current() >>> w, h = self.size() >>> self.resize(w + 10, h + 10)
- move(bbox)[source]¶
CommandLine
# List windows wmctrl -l # List desktops wmctrl -d # Window info xwininfo -id 60817412 python -m vimtk.xctrl XWindow.move joncrall 0+1920,680,400,600,400 python -m vimtk.xctrl XWindow.move joncrall [0,0,1000,1000] python -m vimtk.xctrl XWindow.move GVIM special2 python -m vimtk.xctrl XWindow.move joncrall special2 python -m vimtk.xctrl XWindow.move x-terminal-emulator.X-terminal-emulator [0,0,1000,1000]
CommandLine
python -m vimtk.xctrl XWindow.move
CommandLine
python -m vimtk.xctrl XCtrl.move_window
Example
>>> # xdoctest: +SKIP >>> XCtrl.move_window('joncrall', '[0,0,1000,1000]')
- class vimtk.xctrl.XCtrl[source]¶
Bases:
object
xdotool key ctrl+shift+i
References
http://superuser.com/questions/382616/detecting-currently-active-window http://askubuntu.com/questions/455762/xbindkeys-wont-work-properly
CommandLine
python -m vimtk.xctrl XCtrl:0
Example
>>> # xdoctest: +SKIP >>> # Script >>> orig_window = [] >>> copy_text_to_clipboard(lorium_ipsum()) >>> doscript = [ >>> ('focus', 'x-terminal-emulator.X-terminal-emulator'), >>> ('type', '%paste'), >>> ('key', 'KP_Enter'), >>> # ('focus', 'GVIM') >>> ] >>> XCtrl.do(*doscript, sleeptime=.01)
- classmethod findall_window_ids(pattern=None)[source]¶
- Returns:
wmctl ids for the matching windows
- Return type:
List[int]
CommandLine
python -m vimtk.xctrl XCtrl.findall_window_ids --pat=gvim --noskip python -m vimtk.xctrl XCtrl.findall_window_ids --pat=gvim python -m vimtk.xctrl XCtrl.findall_window_ids --pat=joncrall
Example
>>> # xdoctest: +REQUIRES(--noskip) >>> from vimtk.xctrl import * # NOQA >>> pattern = ub.argval('--pat') >>> winid_list = XCtrl.findall_window_ids(pattern) >>> print('winid_list = {!r}'.format(winid_list))
- classmethod sort_window_ids(winid_list, order='mru')[source]¶
Orders window ids by most recently used
- static killold(pattern, num=4)[source]¶
Leaves no more than num instances of a program alive. Ordering is determined by most recent usage.
CommandLine
python -m vimtk.xctrl XCtrl.killold gvim 2
Example
>>> # xdoctest: +SKIP >>> XCtrl = xctrl.XCtrl >>> pattern = 'gvim' >>> num = 2
- static sorted_window_ids(order='mru')[source]¶
Returns window ids orderd by criteria default is mru (most recently used)
CommandLine
xprop -root | grep "^_NET_CLIENT_LIST_STACKING" | tr "," " " python -m vimtk.xctrl XCtrl.sorted_window_ids
CommandLine
python -m vimtk.xctrl XCtrl.sorted_window_ids
Example
>>> # xdoctest: +SKIP >>> winid_order = XCtrl.sorted_window_ids() >>> print('winid_order = {!r}'.format(winid_order))
- static find_window_id(pattern, method='mru', error='raise')[source]¶
xprop -id 0x00a00007 | grep “WM_CLASS(STRING)”
- static current_gvim_edit(op='e', fpath='')[source]¶
CommandLine
python -m vimtk.xctrl XCtrl.current_gvim_edit sp ~/.bashrc
- static copy_gvim_to_terminal_script('print("hi")', verbose=1)[source]¶
python -m vimtk.xctrl XCtrl.copy_gvim_to_terminal_script “echo hi” 1 1
If this doesn’t work make sure pyperclip is installed and set to xsel
print(‘foobar’) echo hi