Hi Daniel,
this is my orca-custom file, for some functions you need other cli tools: #<FileStart> # display Clipboard (Orca + r) # display Battery (Orca + a) # display Workspace (Orca + d) # display Version (Orca + w) # display translation EN -> DE (Orca + y) # display translation DE -> EN (Orca + c) # Set translation DE -> EN to Clipboard (Orca + x) # Set translation DE -> EN to Clipboard (Orca + v) # for Orca Screenreader # -*- coding: utf-8 -*- #Python from __future__ import division import glob import os import subprocess #GTK/GDK from gi.repository import Gtk, Gdk # Orca import orca.orca import orca.input_event import orca.settings import orca.keybindings import orca.speech import orca.braille ########## Version = "1.4" ########## #Bind Function to key------------------------- myKeyBindings = orca.keybindings.KeyBindings() def DefineShortcut(pHandle,pShortcut): myKeyBindings.add(orca.keybindings.KeyBinding( pShortcut, 1 << orca.keybindings.MODIFIER_ORCA, 1 << orca.keybindings.MODIFIER_ORCA, pHandle)) orca.settings.keyBindingsMap["default"] = myKeyBindings #Bind Function to key+++++++++++ #Convert To Raw --------------- escape_dict={'\a':r'\a', '\b':r'\b', '\c':r'\c', '\f':r'\f', '\n':r' ', '\r':r'\r', '\t':r'\t', '\v':r'\v', '\'':r'\'', '\"':r'\"', '\0':r'\0', '\1':r'\1', '\2':r'\2', '\3':r'\3', '\4':r'\4', '\5':r'\5', '\6':r'\6', '\7':r'\7', '\8':r'\8', '\9':r'\9', "'" : r" ", '"' : r' Anfürhungszeichen '} def raw_string(text): """Returns a raw string representation of text""" new_string='' for char in text: try: new_string+=escape_dict[char] except KeyError: new_string+=char return new_string #Convert To Raw++++++++++++++ #Set to Clipboard def setTextToClipboard(text): ClipboardObj = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) ClipboardObj.set_text(text, -1) #Display Message ---------------------------- #Speak or Braille def outputMessage(Message): if (orca.settings.enableSpeech): orca.speech.speak(Message) if (orca.settings.enableBraille): orca.braille.displayMessage(Message) #Display Message +++++++++++++ #Display Version----------------------------- def displayVersion(script, inputEvent=None): outputMessage("Version " + Version) # define VersionHandler displayVersionHandler = orca.input_event.InputEventHandler( displayVersion, "Gebe die Version der orca-customizations.py aus") #Speak Version of orca-customizations #Display Version++++++++++++++ #Display Clipboard------------------------------- def displayClipboard(script, inputEvent=None): Message = "" FoundClipboardContent = False # Get Clipboard ClipboardObj = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) ClipboardText = ClipboardObj.wait_for_text() ClipboardImage = ClipboardObj.wait_for_image() if (ClipboardText != None): FoundClipboardContent = True if (ClipboardObj.wait_is_uris_available()): UriList = ClipboardText.split('\n') ObjectNo = 0 for Uri in UriList: ObjectNo += 1 if (os.path.isdir(Uri)): Message = Message + "Ordner " #Folder if (os.path.isfile(Uri)): Message = Message + "Datei " #File if (os.path.ismount(Uri)): Message = Message + "Datenträger " #Mountpoint if (os.path.islink(Uri)): Message = Message + "Verknüpfung " #Link #Message = Message + " " + Uri Message = Message + " " + Uri[Uri.rfind('/') + 1:] if (ObjectNo > 1): Message = str(ObjectNo) + " Objekte in der Zwischenablage " + Message # X Objects in Clipboard Object Object else: Message = str(ObjectNo) + " Objekt in der Zwischenablage " + Message # 1 Object in Clipboard Object else: Message = "Text in Zwischenablage " + ClipboardText # Text in Clipboard if (ClipboardImage != None): FoundClipboardContent = True Message = "Ein Bild ist in der Zwischenablage" # Image is in Clipboard if (not FoundClipboardContent): Message = "Zwischenablage ist leer" #Clipboard is empty # Say/braille something. outputMessage(Message) # Consume the event so it will not go to an application. return True # define ClipboardHandler displayClipboardHandler = orca.input_event.InputEventHandler( displayClipboard, "Gebe Inhalt der Zwischenabglage wieder") #Speak Content of the Clipboard #Display Clipboard++++++++++++++++++++++++++++++ #Display Battery State----------------------------------- def displayBatteryStatus(script, inputEvent=None): Battery = 0 for BatteryPath in glob.glob("/sys/class/power_supply/BAT?"): Battery += 1 try: BatteryStatus = open(BatteryPath + "/status", "r") Status = BatteryStatus.read() BatteryStatus.close() Message = Status if Status.find("Full") == 0: # Battery is Full Message = "Akku " + str(Battery) + " ist voll geladen" #Battery is full else: BatteryFull = open(BatteryPath + "/charge_full", "r") Full = int( BatteryFull.read()) BatteryFull.close() BatteryCurrent = open(BatteryPath + "/charge_now", "r") Current = int( BatteryCurrent.read()) if Status.find("Charging") == 0: # Label for Battery Charging Status = "Akku " +str(Battery)+" " + " laden" # Charging if Status.find("Discharging") == 0: # Label for Battery Discharging Status = "Akku " +str(Battery)+" " + " entladen" # Discharging Percent = int( Current / Full * 100) # Charging/Discharging XX Percent Message = Status + " "+ str( Percent) + " Prozent" #Percent #print Message #Debugging #print Percent #Debugging #print Status #Debugging except IOError: # Battery not found or cant open. Message = "Akku " +str(Battery) + " kann nicht geöffnent werden." # Battery can not open outputMessage(Message) if (Battery == 0): Message = "Kein Akku gefunden." outputMessage(Message) # Consume the event so it will not go to an application. return True # define BatteryStatusHandler displayBatteryStatusHandler = orca.input_event.InputEventHandler( displayBatteryStatus, "Spreche den Status des Akkus") # Speak state of battery #Display Battery State+++++++++++++++++++++++++++++++++++ #Display Workspace No------------------------------- def displayWorkspaceNo(script, inputEvent=None): Message = "Desktop " try: xprop = os.popen('xprop -root _NET_CURRENT_DESKTOP').read() xprop = xprop[:-1] if xprop != '': xprop = xprop[xprop.find("=")+ 2 :] else: xprop = "konnte nicht ermittelt werden" # cant get desktop number Message = Message + xprop except IOError: # xprop evtl. not installed Message = "Bitte xprop installieren." #please install xprop # Say/braille something. outputMessage(Message) # Consume the event so it will not go to an application. return True # define WorkspaceNoHandler displayWorkspaceNoHandler = orca.input_event.InputEventHandler( displayWorkspaceNo, "Aktuelle Desktopnummer sprechen") #display current workspace #Display Workspace No++++++++++++++++++++++++++++++ #Display Clipboard Translation------------------------------- def displayClipboardTranslation(languageService, toClipboard): Message = "" # Get Selection ClipboardObj = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) ClipboardText = ClipboardObj.wait_for_text() if (ClipboardText != None): ClipboardText = raw_string(ClipboardText) TranslationText = os.popen('trs {='+ languageService +'} "'+ ClipboardText +'"').read() TranslationText = TranslationText[:-1] if TranslationText in '/bin/sh: trs: ': Message = "Bitte TRS installieren" # install tw (TranslateWord) else: #TranslationText = ClipboardText = raw_string(TranslationText) if toClipboard: setTextToClipboard(TranslationText) Message = "Neue Zwischenabglage " + TranslationText # Text in Clipboard else: Message = "Übersetzt " + TranslationText # Text in Clipboard else: Message = "Zwischenablage ist leer" #Clipboard is empty # Say/braille something. outputMessage(Message) # Consume the event so it will not go to an application. return True # define Handler Generators def displayClipboardEnglishInGermanTranslation(script, inputEvent=None): displayClipboardTranslation('de', False) return True def displayAndSetClipboardEnglishInGermanTranslation(script, inputEvent=None): displayClipboardTranslation( 'de', True) return True def displayClipboardGermanInEnglishTranslation(script, inputEvent=None): displayClipboardTranslation( 'en', False) return True def displayAndSetClipboardGermanInEnglishTranslation(script, inputEvent=None): displayClipboardTranslation( 'en', True) return True # define Clipboard Translation Handler displayDeClipboardTranslationHandler = orca.input_event.InputEventHandler( displayClipboardEnglishInGermanTranslation, "Übersetzt den Text in der Zwischenabglage auf Deutsch") #Translate the Text in Clipboard displaySetEnClipboardTranslationHandler = orca.input_event.InputEventHandler( displayAndSetClipboardGermanInEnglishTranslation, "Ersetzt den Text in der Zwischenablage durch seine englische Übersetzung") #Translate the Text in Clipboard and paste in clipboard displayEnClipboardTranslationHandler = orca.input_event.InputEventHandler( displayClipboardGermanInEnglishTranslation, "Übersetzt den Text in der Zwischenabglage auf Englisch") #Translate the Text in Clipboard displaySetDeClipboardTranslationHandler = orca.input_event.InputEventHandler( displayAndSetClipboardEnglishInGermanTranslation, "Ersetzt den Text in der Zwischenablage durch seine deutsche Übersetzung") #Translate the Text in Clipboard and paste in clipboard #Display Clipboard Translation++++++++++++++++++++++++++++++ #Monitor OnOff------------------------------- def toggleMonitor(OnOff): try: temp = os.popen('sudo vbetool dpms '+OnOff).read() if 'on': Message = "Monitor angeschaltet." if 'off': Message = "Monitor ausgeschaltet." except IOError: # vbetool evtl. not installed Message = "Bitte vbetool installieren." #please install vbetool # Say/braille something. outputMessage(Message) # Consume the event so it will not go to an application. return True # Define Handler def toggleMonitorOn(script, inputEvent=None): toggleMonitor( 'on') return True def toggleMonitorOff(script, inputEvent=None): toggleMonitor( 'off') return True toggleMonitorOnHandler = orca.input_event.InputEventHandler( toggleMonitorOn, "Schalte Monitor an.") #Monitor ON toggleMonitorOffHandler = orca.input_event.InputEventHandler( toggleMonitorOff, "Schalte Monitor aus.") #Monitor Off #Monitor OnOff++++++++++++++++++++++++++++++++++++ #define shortcuts DefineShortcut(displayClipboardHandler,"r") # Shortcut Orca + r DefineShortcut(displayWorkspaceNoHandler,"d")# Shortcut Orca + d DefineShortcut(displayBatteryStatusHandler,"a")# Shortcut Orca + a DefineShortcut(displayVersionHandler,"w")# Shortcut Orca + w DefineShortcut(displayDeClipboardTranslationHandler,"y")# Shortcut Orca + y DefineShortcut(displayEnClipboardTranslationHandler,"c")# Shortcut Orca + c DefineShortcut(displaySetDeClipboardTranslationHandler,"x")# Shortcut Orca + x DefineShortcut(displaySetEnClipboardTranslationHandler,"v")# Shortcut Orca + v DefineShortcut(toggleMonitorOnHandler,"b")# Shortcut Orca + b DefineShortcut(toggleMonitorOffHandler,"n")# Shortcut Orca + n #<FileEnd> Am 13.12.2014 um 21:34 schrieb Daniel Barich:
|