Applied same fix for export to X to import as well.
This commit is contained in:
parent
619b67ea70
commit
1649f18a8f
@ -8,7 +8,6 @@ from fenrirscreenreader.core import debug
|
|||||||
import subprocess, os
|
import subprocess, os
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
import _thread
|
import _thread
|
||||||
|
|
||||||
class command():
|
class command():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
@ -21,19 +20,27 @@ class command():
|
|||||||
return _("imports the graphical clipboard to Fenrir's clipboard")
|
return _("imports the graphical clipboard to Fenrir's clipboard")
|
||||||
def run(self):
|
def run(self):
|
||||||
_thread.start_new_thread(self._threadRun , ())
|
_thread.start_new_thread(self._threadRun , ())
|
||||||
|
|
||||||
def _threadRun(self):
|
def _threadRun(self):
|
||||||
try:
|
try:
|
||||||
|
# Find xclip path
|
||||||
|
xclip_paths = ['/usr/bin/xclip', '/bin/xclip', '/usr/local/bin/xclip']
|
||||||
|
xclip_path = None
|
||||||
|
for path in xclip_paths:
|
||||||
|
if os.path.isfile(path) and os.access(path, os.X_OK):
|
||||||
|
xclip_path = path
|
||||||
|
break
|
||||||
|
if not xclip_path:
|
||||||
|
self.env['runtime']['outputManager'].presentText('xclip not found in common locations', interrupt=True)
|
||||||
|
return
|
||||||
xClipboard = ''
|
xClipboard = ''
|
||||||
for display in range(10):
|
for display in range(10):
|
||||||
p = Popen('su ' + self.env['general']['currUser'] + ' -c "xclip -d :0 -o"' , stdout=PIPE, stderr=PIPE, shell=True)
|
p = Popen('su ' + self.env['general']['currUser'] + ' -p -c "' + xclip_path + ' -d :' + str(display) + ' -o"', stdout=PIPE, stderr=PIPE, shell=True)
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
self.env['runtime']['outputManager'].interruptOutput()
|
self.env['runtime']['outputManager'].interruptOutput()
|
||||||
stderr = stderr.decode('utf-8')
|
stderr = stderr.decode('utf-8')
|
||||||
xClipboard = stdout.decode('utf-8')
|
xClipboard = stdout.decode('utf-8')
|
||||||
if (stderr == ''):
|
if (stderr == ''):
|
||||||
break
|
break
|
||||||
|
|
||||||
if stderr != '':
|
if stderr != '':
|
||||||
self.env['runtime']['outputManager'].presentText(stderr , soundIcon='', interrupt=False)
|
self.env['runtime']['outputManager'].presentText(stderr , soundIcon='', interrupt=False)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user