From 3ec1a571463d9b01fcd0dabe6d6f9bf577ac2d48 Mon Sep 17 00:00:00 2001 From: chrys Date: Mon, 11 Jun 2018 23:10:08 +0200 Subject: [PATCH] Revert "Revert "wire up most suff for export to X"" This reverts commit 38aeb4108285280be1ca706a88deec6bd9b8412b. --- .../commands/commands/import_clipboard_from_x.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/fenrirscreenreader/commands/commands/import_clipboard_from_x.py b/src/fenrirscreenreader/commands/commands/import_clipboard_from_x.py index 65c9a28c..a4f6123b 100644 --- a/src/fenrirscreenreader/commands/commands/import_clipboard_from_x.py +++ b/src/fenrirscreenreader/commands/commands/import_clipboard_from_x.py @@ -24,25 +24,22 @@ class command(): def _threadRun(self): try: - if self.env['runtime']['memoryManager'].isIndexListEmpty('clipboardHistory'): - self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True) - return - clipboard = self.env['runtime']['memoryManager'].getIndexListElement('clipboardHistory') + xClipboard = '' for display in range(10): p = Popen('su ' + self.env['general']['currUser'] + ' -c "echo -n \\\"' + clipboard.replace('"','\\\\\\"') +'\\\" | xclip -d :' + str(display) + ' -o"' , stdout=PIPE, stderr=PIPE, shell=True) stdout, stderr = p.communicate() self.env['runtime']['outputManager'].interruptOutput() - #screenEncoding = self.env['runtime']['settingsManager'].getSetting('screen', 'encoding') stderr = stderr.decode('utf-8') - stdout = stdout.decode('utf-8') + xClipboard = stdout.decode('utf-8') if (stderr == ''): break - #stderr = stderr.decode(screenEncoding, "replace").encode('utf-8').decode('utf-8') - #stdout = stdout.decode(screenEncoding, "replace").encode('utf-8').decode('utf-8') + if stderr != '': self.env['runtime']['outputManager'].presentText(stderr , soundIcon='', interrupt=False) else: - self.env['runtime']['outputManager'].presentText('imported from the X session.', interrupt=True) + self.env['runtime']['memoryManager'].addValueToFirstIndex('clipboardHistory', xClipboard) + self.env['runtime']['outputManager'].presentText('Import to Clipboard', soundIcon='CopyToClipboard', interrupt=True) + self.env['runtime']['outputManager'].presentText(imported, soundIcon='', interrupt=False) except Exception as e: self.env['runtime']['outputManager'].presentText(e , soundIcon='', interrupt=False)