diff --git a/config/keyboard/desktop.conf b/config/keyboard/desktop.conf index c0bd40b7..1bd486fc 100644 --- a/config/keyboard/desktop.conf +++ b/config/keyboard/desktop.conf @@ -105,6 +105,7 @@ KEY_FENRIR,KEY_PAGEDOWN=next_clipboard KEY_FENRIR,KEY_SHIFT,KEY_C=curr_clipboard KEY_FENRIR,KEY_C=copy_marked_to_clipboard KEY_FENRIR,KEY_V=paste_clipboard +KEY_FENRIR,KEY_W=export_clipboard_to_file KEY_FENRIR,KEY_CTRL,KEY_SHIFT,KEY_X=remove_marks KEY_FENRIR,KEY_X=set_mark KEY_FENRIR,KEY_SHIFT,KEY_X=marked_text diff --git a/config/keyboard/laptop.conf b/config/keyboard/laptop.conf index fd8f3ffb..5947f357 100644 --- a/config/keyboard/laptop.conf +++ b/config/keyboard/laptop.conf @@ -105,6 +105,7 @@ KEY_FENRIR,KEY_PAGEDOWN=next_clipboard KEY_FENRIR,KEY_SHIFT,KEY_C=curr_clipboard KEY_FENRIR,KEY_C=copy_marked_to_clipboard KEY_FENRIR,KEY_V=paste_clipboard +KEY_FENRIR,KEY_W=export_clipboard_to_file KEY_FENRIR,KEY_CTRL,KEY_SHIFT,KEY_X=remove_marks KEY_FENRIR,KEY_X=set_mark KEY_FENRIR,KEY_SHIFT,KEY_X=marked_text diff --git a/config/keyboard/test.conf b/config/keyboard/test.conf index fe2a5055..7b3732c0 100644 --- a/config/keyboard/test.conf +++ b/config/keyboard/test.conf @@ -108,5 +108,6 @@ KEY_FENRIR,KEY_X=set_mark KEY_FENRIR,KEY_SHIFT,KEY_X=marked_text KEY_FENRIR,KEY_C=copy_marked_to_clipboard #KEY_FENRIR,KEY_V=paste_clipboard +KEY_FENRIR,KEY_W=export_clipboard_to_file # linux specific KEY_FENRIR,KEY_V=export_clipboard_to_x diff --git a/config/settings/espeak.settings.conf b/config/settings/espeak.settings.conf index 37b27bb1..eb2b95cd 100644 --- a/config/settings/espeak.settings.conf +++ b/config/settings/espeak.settings.conf @@ -151,6 +151,9 @@ punctuationLevel=some respectPunctuationPause=True newLinePause=True numberOfClipboards=10 +# used path for "export_clipboard_to_file" +# $user is replaced by username +clipboardExportPath=/tmp/fenrirClipboard emoticons=True # define the current fenrir key fenrirKeys=KEY_KP0,KEY_META diff --git a/config/settings/settings.conf b/config/settings/settings.conf index 2b32e45f..d055a363 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -153,6 +153,10 @@ punctuationLevel=some respectPunctuationPause=True newLinePause=True numberOfClipboards=10 +# used path for "export_clipboard_to_file" +# $user is replaced by username +#clipboardExportPath=/home/$user/fenrirClipboard +clipboardExportPath=/tmp/fenrirClipboard emoticons=True # define the current fenrir key fenrirKeys=KEY_KP0,KEY_META,KEY_INSERT diff --git a/config/settings/settings.conf.storm b/config/settings/settings.conf.storm index 75129d05..b4e00d7c 100644 --- a/config/settings/settings.conf.storm +++ b/config/settings/settings.conf.storm @@ -104,6 +104,9 @@ punctuationLevel=some respectPunctuationPause=True newLinePause=True numberOfClipboards=10 +# used path for "export_clipboard_to_file" +# $user is replaced by username +clipboardExportPath=/tmp/fenrirClipboard emoticons=True fenrirKeys=KEY_KP0,KEY_META scriptKey=KEY_COMPOSE diff --git a/src/fenrir/commands/commands/export_clipboard_to_file.py b/src/fenrir/commands/commands/export_clipboard_to_file.py new file mode 100644 index 00000000..825214d7 --- /dev/null +++ b/src/fenrir/commands/commands/export_clipboard_to_file.py @@ -0,0 +1,46 @@ +#!/bin/python +# -*- coding: utf-8 -*- + +# Fenrir TTY screen reader +# By Chrys, Storm Dragon, and contributers. + +from core import debug + +class command(): + def __init__(self): + pass + def initialize(self, environment, scriptPath=''): + self.env = environment + + def shutdown(self): + pass + def getDescription(self): + return _('export the current fenrir clipboard to a file') + def run(self): + clipboardFilePath = self.env['runtime']['settingsManager'].getSetting('general', 'clipboardExportPath') + clipboardFilePath = clipboardFilePath.replace('$user',self.env['general']['currUser']) + clipboardFilePath = clipboardFilePath.replace('$USER',self.env['general']['currUser']) + clipboardFilePath = clipboardFilePath.replace('$User',self.env['general']['currUser']) + clipboardFile = open(clipboardFilePath,'w') + try: + currClipboard = self.env['commandBuffer']['currClipboard'] + if currClipboard < 0: + self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True) + return + if not self.env['commandBuffer']['clipboard']: + self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True) + return + if not self.env['commandBuffer']['clipboard'][currClipboard]: + self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True) + return + if self.env['commandBuffer']['clipboard'][currClipboard] == '': + self.env['runtime']['outputManager'].presentText(_('clipboard empty'), interrupt=True) + return + clipboardFile.write(self.env['commandBuffer']['clipboard'][currClipboard]) + clipboardFile.close() + self.env['runtime']['outputManager'].presentText(_('clipboard exported to file'), interrupt=True) + except Exception as e: + self.env['runtime']['debug'].writeDebugOut('export_clipboard_to_file:run: Filepath:'+ clipboardFile +' trace:' + str(e),debug.debugLevel.ERROR) + + def setCallback(self, callback): + pass