-
Notifications
You must be signed in to change notification settings - Fork 0
/
launchbar.py
57 lines (45 loc) · 1.42 KB
/
launchbar.py
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
#!/usr/bin/python3
import os
import subprocess
import re
from urllib.parse import quote_plus
DEBUG = os.getenv('LB_ACTION_PATH') is None
def getenv(key, default=None):
if DEBUG:
if re.match(r'LB_.*_PATH', key):
return os.path.curdir
elif re.match(r'LB_.*_KEY', key):
return "1"
else:
return os.getenv(key, default)
class LaunchBar:
@staticmethod
def is_shift_key():
return getenv('LB_OPTION_SHIFT_KEY') == "1"
@staticmethod
def is_command_key():
return getenv('LB_OPTION_COMMAND_KEY') == "1"
@staticmethod
def is_control_key():
return getenv('LB_OPTION_CONTROL_KEY') == "1"
@staticmethod
def is_space_key():
return getenv('LB_OPTION_SPACE_KEY') == "1"
@staticmethod
def is_alternate_key():
return getenv('LB_OPTION_ALTERNATE_KEY') == "1"
@staticmethod
def hide():
subprocess.call(['osascript', '-e', 'tell application "LaunchBar" to hide'])
@staticmethod
def large_type(msg):
subprocess.call(['open', 'x-launchbar:large-type?string={}'.format(quote_plus(msg))])
@staticmethod
def cache_path():
return getenv('LB_CACHE_PATH')
@staticmethod
def support_path():
return getenv('LB_SUPPORT_PATH')
@staticmethod
def resources_path():
return os.path.join(getenv('LB_ACTION_PATH'), 'Contents', 'Resources')