-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy path__init__.py
More file actions
65 lines (49 loc) · 1.9 KB
/
Copy path__init__.py
File metadata and controls
65 lines (49 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import sublime
import time
import os
from ..clipboard import clipboard
from subprocess import CalledProcessError
plat = sublime.platform()
if plat == "linux":
from ..xdotool import xdotool
def send_to_linux_terminal(linux_window_name, linux_terminal, cmd_list):
wids = get_linux_wids(linux_window_name, linux_terminal)
wid = wids.decode("utf-8").strip().split("\n")[-1]
if isinstance(cmd_list, str):
cmd_list = [cmd_list]
sublime_id = xdotool("getactivewindow")
if os.environ.get("XDG_SESSION_DESKTOP") == "KDE":
xdotool("windowactivate", wid)
time.sleep(0.05)
else:
xdotool("windowfocus", wid)
for cmd in cmd_list:
clipboard.set_clipboard(cmd)
if cmd:
xdotool("key", "ctrl+shift+v")
time.sleep(0.1)
xdotool("key", "Return")
time.sleep(0.1)
clipboard.reset_clipboard()
if os.environ.get("XDG_SESSION_DESKTOP") == "KDE":
xdotool("windowactivate", sublime_id)
else:
xdotool("windowfocus", sublime_id)
def get_linux_wids(linux_window_name, linux_terminal):
if linux_window_name:
try:
wids = xdotool("search", "--onlyvisible", "--name", linux_window_name)
except CalledProcessError:
sublime.status_message("{} (WM_NAME) not found; trying {} (WM_CLASS)"
.format(linux_window_name, linux_terminal))
wids = xdotool("search", "--onlyvisible", "--class", linux_terminal)
else:
wids = xdotool("search", "--onlyvisible", "--class", linux_terminal)
if not wids:
raise Exception("{} not found.".format(linux_terminal))
return wids
else:
def send_to_linux_terminal(cmd):
pass
def get_linux_wids(cmd):
pass