From 3b91bb5a724c91ee02b55e4431c283d9c21f2970 Mon Sep 17 00:00:00 2001 From: chrys Date: Tue, 12 Sep 2017 00:50:10 +0200 Subject: [PATCH 1/6] make export clipboard to X inital working --- src/fenrir/commands/commands/export_clipboard_to_x.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/fenrir/commands/commands/export_clipboard_to_x.py b/src/fenrir/commands/commands/export_clipboard_to_x.py index 0497199f..d137ab7b 100644 --- a/src/fenrir/commands/commands/export_clipboard_to_x.py +++ b/src/fenrir/commands/commands/export_clipboard_to_x.py @@ -46,12 +46,14 @@ class command(): print('4') return print('doit') - p = Popen('su -c "echo -n \"' + self.env['commandBuffer']['clipboard'][currClipboard] +'\" | xclip -d :0 -selection c' + self.env['general']['currUser'] , stdout=PIPE, stderr=PIPE, shell=True) + p = Popen('su ' + self.env['general']['currUser'] + ' -c "echo -n \"' + self.env['commandBuffer']['clipboard'][currClipboard] +'\" | xclip -d :0 -selection c"' , 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(screenEncoding, "replace").encode('utf-8').decode('utf-8') - stdout = stdout.decode(screenEncoding, "replace").encode('utf-8').decode('utf-8') + #screenEncoding = self.env['runtime']['settingsManager'].getSetting('screen', 'encoding') + stderr = stderr.decode('utf-8') + stdout = stdout.decode('utf-8') + #stderr = stderr.decode(screenEncoding, "replace").encode('utf-8').decode('utf-8') + #stdout = stdout.decode(screenEncoding, "replace").encode('utf-8').decode('utf-8') print('test:',stderr,stdout) if stderr != '': self.env['runtime']['outputManager'].presentText(stdout , soundIcon='', interrupt=False) From 4da95a1b8b53cad3bd505a88c0ca3b4ee14237e7 Mon Sep 17 00:00:00 2001 From: chrys Date: Tue, 12 Sep 2017 01:08:12 +0200 Subject: [PATCH 2/6] polish export to X --- .../commands/export_clipboard_to_x.py | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/fenrir/commands/commands/export_clipboard_to_x.py b/src/fenrir/commands/commands/export_clipboard_to_x.py index d137ab7b..bf008926 100644 --- a/src/fenrir/commands/commands/export_clipboard_to_x.py +++ b/src/fenrir/commands/commands/export_clipboard_to_x.py @@ -31,36 +31,32 @@ class command(): if currClipboard < 0: self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True) - print('1') return if not self.env['commandBuffer']['clipboard']: self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True) - print('2') return if not self.env['commandBuffer']['clipboard'][currClipboard]: self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True) - print('3') return if self.env['commandBuffer']['clipboard'][currClipboard] == '': self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True) - print('4') return - print('doit') - p = Popen('su ' + self.env['general']['currUser'] + ' -c "echo -n \"' + self.env['commandBuffer']['clipboard'][currClipboard] +'\" | xclip -d :0 -selection c"' , 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') + for display in range(10): + p = Popen('su ' + self.env['general']['currUser'] + ' -c "echo -n \"' + self.env['commandBuffer']['clipboard'][currClipboard] +'\" | xclip -d :' + str(display) + ' -selection c"' , 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') + 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') - print('test:',stderr,stdout) if stderr != '': self.env['runtime']['outputManager'].presentText(stdout , soundIcon='', interrupt=False) else: self.env['runtime']['outputManager'].presentText('export clipboard', soundIcon='PasteClipboardOnScreen', interrupt=True) except Exception as e: - print(e) self.env['runtime']['outputManager'].presentText(e , soundIcon='', interrupt=False) def setCallback(self, callback): From 994700568ec811ac779a57f19baadfc456ef3b1b Mon Sep 17 00:00:00 2001 From: chrys Date: Tue, 12 Sep 2017 01:11:47 +0200 Subject: [PATCH 3/6] remove output --- src/fenrir/commands/commands/export_clipboard_to_x.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/fenrir/commands/commands/export_clipboard_to_x.py b/src/fenrir/commands/commands/export_clipboard_to_x.py index bf008926..51718d11 100644 --- a/src/fenrir/commands/commands/export_clipboard_to_x.py +++ b/src/fenrir/commands/commands/export_clipboard_to_x.py @@ -20,14 +20,11 @@ class command(): def getDescription(self): return _('export the current fenrir clipboard to X clipboard') def run(self): - print('drin') _thread.start_new_thread(self._threadRun , ()) def _threadRun(self): - print('jo') try: currClipboard = self.env['commandBuffer']['currClipboard'] - print(currClipboard) if currClipboard < 0: self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True) @@ -53,7 +50,7 @@ class command(): #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(stdout , soundIcon='', interrupt=False) + self.env['runtime']['outputManager'].presentText(stderr , soundIcon='', interrupt=False) else: self.env['runtime']['outputManager'].presentText('export clipboard', soundIcon='PasteClipboardOnScreen', interrupt=True) except Exception as e: From 0f2606f19fd6d74c682a4d7c98291e5d8bb44af9 Mon Sep 17 00:00:00 2001 From: chrys Date: Tue, 12 Sep 2017 01:20:08 +0200 Subject: [PATCH 4/6] fix qutes --- src/fenrir/commands/commands/export_clipboard_to_x.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/fenrir/commands/commands/export_clipboard_to_x.py b/src/fenrir/commands/commands/export_clipboard_to_x.py index 51718d11..29318ada 100644 --- a/src/fenrir/commands/commands/export_clipboard_to_x.py +++ b/src/fenrir/commands/commands/export_clipboard_to_x.py @@ -39,14 +39,16 @@ class command(): self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True) return for display in range(10): - p = Popen('su ' + self.env['general']['currUser'] + ' -c "echo -n \"' + self.env['commandBuffer']['clipboard'][currClipboard] +'\" | xclip -d :' + str(display) + ' -selection c"' , stdout=PIPE, stderr=PIPE, shell=True) + p = Popen('su ' + self.env['general']['currUser'] + ' -c "echo -n \\\"' + self.env['commandBuffer']['clipboard'][currClipboard] +'\\\" | xclip -d :' + str(display) + ' -selection c"' , 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') if (stderr == ''): - break + break + else: + print(stderr) #stderr = stderr.decode(screenEncoding, "replace").encode('utf-8').decode('utf-8') #stdout = stdout.decode(screenEncoding, "replace").encode('utf-8').decode('utf-8') if stderr != '': @@ -54,7 +56,8 @@ class command(): else: self.env['runtime']['outputManager'].presentText('export clipboard', soundIcon='PasteClipboardOnScreen', interrupt=True) except Exception as e: - self.env['runtime']['outputManager'].presentText(e , soundIcon='', interrupt=False) + print(e) + self.env['runtime']['outputManager'].presentText(e , soundIcon='', interrupt=False) def setCallback(self, callback): pass From 8a3a3108c9d589ce9296db63a96444770611dd7e Mon Sep 17 00:00:00 2001 From: chrys Date: Tue, 12 Sep 2017 01:23:46 +0200 Subject: [PATCH 5/6] change message, remove soundIcon --- src/fenrir/commands/commands/export_clipboard_to_x.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/fenrir/commands/commands/export_clipboard_to_x.py b/src/fenrir/commands/commands/export_clipboard_to_x.py index 29318ada..8e8a1ca4 100644 --- a/src/fenrir/commands/commands/export_clipboard_to_x.py +++ b/src/fenrir/commands/commands/export_clipboard_to_x.py @@ -46,17 +46,14 @@ class command(): stderr = stderr.decode('utf-8') stdout = stdout.decode('utf-8') if (stderr == ''): - break - else: - print(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('export clipboard', soundIcon='PasteClipboardOnScreen', interrupt=True) + self.env['runtime']['outputManager'].presentText('pasted to the X session or clipboard.', interrupt=True) except Exception as e: - print(e) self.env['runtime']['outputManager'].presentText(e , soundIcon='', interrupt=False) def setCallback(self, callback): From 2b3c1a172821b269d4dbc529cc3aa6dbab48c504 Mon Sep 17 00:00:00 2001 From: chrys Date: Tue, 12 Sep 2017 02:21:06 +0200 Subject: [PATCH 6/6] fix quote for real --- src/fenrir/commands/commands/export_clipboard_to_x.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fenrir/commands/commands/export_clipboard_to_x.py b/src/fenrir/commands/commands/export_clipboard_to_x.py index 8e8a1ca4..8c11945e 100644 --- a/src/fenrir/commands/commands/export_clipboard_to_x.py +++ b/src/fenrir/commands/commands/export_clipboard_to_x.py @@ -39,7 +39,7 @@ class command(): self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True) return for display in range(10): - p = Popen('su ' + self.env['general']['currUser'] + ' -c "echo -n \\\"' + self.env['commandBuffer']['clipboard'][currClipboard] +'\\\" | xclip -d :' + str(display) + ' -selection c"' , stdout=PIPE, stderr=PIPE, shell=True) + p = Popen('su ' + self.env['general']['currUser'] + ' -c "echo -n \\\"' + self.env['commandBuffer']['clipboard'][currClipboard].replace('"','\\\\\\"') +'\\\" | xclip -d :' + str(display) + ' -selection c"' , stdout=PIPE, stderr=PIPE, shell=True) stdout, stderr = p.communicate() self.env['runtime']['outputManager'].interruptOutput() #screenEncoding = self.env['runtime']['settingsManager'].getSetting('screen', 'encoding') @@ -52,7 +52,7 @@ class command(): if stderr != '': self.env['runtime']['outputManager'].presentText(stderr , soundIcon='', interrupt=False) else: - self.env['runtime']['outputManager'].presentText('pasted to the X session or clipboard.', interrupt=True) + self.env['runtime']['outputManager'].presentText('exported to the X session.', interrupt=True) except Exception as e: self.env['runtime']['outputManager'].presentText(e , soundIcon='', interrupt=False)