forked from friday/ulauncher-clipboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCopyQ.py
27 lines (20 loc) · 865 Bytes
/
CopyQ.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
import subprocess
import json
from lib import logger, execGet, tryOr, findExec, pidOf
name = 'CopyQ'
client = 'copyq'
def canStart():
return bool(findExec(client))
def isRunning():
return bool(pidOf(client))
def isEnabled():
# activated and configured to sync clipboard
# The "Auto" option detection logic will disfavor copyq when not running because it will show as disabled
return isRunning() and execGet(client, 'eval', 'monitoring() && config("check_clipboard")') == 'true'
def start():
# Open and don't wait
subprocess.Popen([client])
def getHistory():
# CopyQ uses QT's JS implementation for scripting, which doesn't support modern JS
script = "history = []; for (var ind = 0; ind < size(); ind += 1) { history.push(str(read(ind))); }; JSON.stringify(history)"
return json.loads(execGet(client, 'eval', script))