"""This script adds extra functionality to Orca Some information retrieved by this script can be pasted from the clipboard This script automatically generated by http://www.stormdragon.us/orca-customizations/ Feel free to modify and/or redistribute this script as you see fit.""" import orca.input_event # watches for input that Orca recognizes import orca.keybindings # Handles binding keystrokes for Orca to use. import orca.orca # Imports the main screen reader import orca.speech # Handles Orca's speaking abilities import orca.braille # Displays information in Braille format import subprocess import os import time #variable section #Postal code for weather information: zipCode = "28624" myKeyBindings = orca.keybindings.KeyBindings() #places text in the clipboard def setClipboardText(text): os.system("echo \"" + text + "\" | xclip -selection clipboard") #getWeather function gets weather from Yahoo def getWeather(zip_code, forecast = False): if zip_code != "0": weatherReport = subprocess.check_output(["weatherman -e " + zip_code]) setClipboardText(weatherReport) return weatherReport #define the battery status function def sayBattery(script, inputEvent=None): message = subprocess.check_output(["acpi"]) if len(message) == 0: message = "Battery not found." orca.speech.speak(message) orca.braille.displayMessage(message) return True #end battery status function #define the readClipboard function def readClipboard(script, inputEvent=None): #Get the clipboard cbText = subprocess.check_output(["xclip -o -selection clipboard"]) if len(cbText) == 0: cbText = "No text in clipboard." #Speak and braille the info orca.speech.speak(cbText) orca.braille.displayMessage(cbText) #end readClipboard function #Define the sayTime function def sayTime(script, inputEvent=None): message = time.strftime("%I:%M%p", time.localtime()) orca.speech.speak(message) orca.braille.displayMessage(message) setClipboardText(message) return True #end sayTime function #Define the sayDate function def sayDate(script, inputEvent=None): message = time.strftime("%A, %B %d, %Y", time.localtime()) orca.speech.speak(message) orca.braille.displayMessage(message) setClipboardText(message) return True #end sayDate function #Define the sayVersion function def sayVersion(script, inputEvent=None): message = "Orca version " + orca.orca_platform.version orca.speech.speak(message) orca.braille.displayMessage(message) setClipboardText(message) return True #end sayVersion function #Define the sayWeather function def sayWeather(script, inputEvent=None): message = getWeather(zipCode) orca.speech.speak(message) orca.braille.displayMessage(message) return True #end sayWeather function #Define the sayForecast function def sayForecast(script, inputEvent=None): message = getWeather(zipCode, True) orca.speech.speak(message) orca.braille.displayMessage(message) return True #end sayForecast function #Define the increase volume function #By Hammer Attila #The following function increases master volume by 3 steps, and speaks the new volume def increasevolume(script, inputEvent=None): #The following command increases volume by 3 steps subprocess.check_output(['amixer sset Master 3+']) #The following command gets increased master volume percentage volume=subprocess.check_output(['amixer get Master|grep %|cut -d "[" -f2']) #Finally, speak the new increased volume value orca.speech.speak(volume) orca.braille.displayMessage(volume) #End increase volume function #Define the decrease volume function #By Hammer Attila #The following function decreases master volume by 3 steps, and speaks the new volume def decreasevolume(script, inputEvent=None): #The following command decreases volume by 3 steps subprocess.check_output(['amixer sset Master 3-']) #The following command gets decreased master volume percentage volume=subprocess.check_output(['amixer get Master|grep %|cut -d "[" -f2']) #Finally, speak the new decreased volume value orca.speech.speak(volume) orca.braille.displayMessage(volume) #End decrease volume function #Define the toggle volume function #By Hammer Attila #The following function toggles master volume mute on/off def togglevolumemute(script, inputEvent=None): #The following command toggles master volume mute on/off subprocess.check_output(['amixer sset Master toggle']) #The following command gets master volume mute status mutestatus=subprocess.check_output(['amixer get Master|grep %|cut -d "[" -f4']) #Finally, if actual master volume status is on, Orca notifies the user that mute is off. if mutestatus=='on]': orca.speech.speak('Mute off.') orca.braille.displayMessage('Mute off.') #End toggle volume function #Set up sayBattery keys sayBatteryHandler = orca.input_event.InputEventHandler( sayBattery, "Speaks and Brailles battery status.") # Shows the function of the key press in learn mode myKeyBindings.add(orca.keybindings.KeyBinding( "a", 1 << orca.settings.MODIFIER_ORCA, 1 << orca.settings.MODIFIER_ORCA, sayBatteryHandler)) # Sets Orca-a as the battery status key #Set up readClipboard keys readClipboardHandler = orca.input_event.InputEventHandler( readClipboard, "Speaks and Brailles clipboard contents.") # Shows the function of the key press in learn mode myKeyBindings.add(orca.keybindings.KeyBinding( "r", 1 << orca.settings.MODIFIER_ORCA, 1 << orca.settings.MODIFIER_ORCA, readClipboardHandler)) # Sets Orca-r as the read clipboard key #Set up sayTime keys sayTimeHandler = orca.input_event.InputEventHandler( sayTime, "Presents the time.") # Shows the function of the key press in learn mode myKeyBindings.add(orca.keybindings.KeyBinding( "t", 1 << orca.settings.MODIFIER_ORCA, 1 << orca.settings.MODIFIER_ORCA, sayTimeHandler)) # Sets the say time key #add sayDate info sayDateHandler = orca.input_event.InputEventHandler( sayDate, "Presents the date.") # Shows the function of the key press in learn mode myKeyBindings.add(orca.keybindings.KeyBinding( "t", 1 << orca.settings.MODIFIER_ORCA, 1 << orca.settings.MODIFIER_ORCA, sayDateHandler, 2)) # Sets the say date key #Set up sayVersion keys sayVersionHandler = orca.input_event.InputEventHandler( sayVersion, "Presents the version of Orca.") # Shows the function of the key press in learn mode myKeyBindings.add(orca.keybindings.KeyBinding( "v", 1 << orca.settings.MODIFIER_ORCA, 1 << orca.settings.MODIFIER_ORCA, sayVersionHandler)) # Sets the say time key #add sayWeather info sayWeatherHandler = orca.input_event.InputEventHandler( sayWeather, "Get current temperature and conditions.") # Shows the function of the key press in learn mode myKeyBindings.add(orca.keybindings.KeyBinding( "w", 1 << orca.settings.MODIFIER_ORCA, 1 << orca.settings.MODIFIER_ORCA, sayWeatherHandler)) # Sets the say weather key #add sayForecast info sayForecastHandler = orca.input_event.InputEventHandler( sayForecast, "Get extended weather information.") # Shows the function of the key press in learn mode myKeyBindings.add(orca.keybindings.KeyBinding( "w", 1 << orca.settings.MODIFIER_ORCA, 1 << orca.settings.MODIFIER_ORCA, sayForecastHandler, 2)) # Sets the say weather key #Add increase volume info increasevolumeHandler = orca.input_event.InputEventHandler( increasevolume, "Increases master volume by 3 steps, and speaks the new value") # Shows the function of the key press in learn mode myKeyBindings.add(orca.keybindings.KeyBinding( "Page_Up", orca.settings.ORCA_MODIFIER_MASK, orca.settings.ORCA_MODIFIER_MASK, increasevolumeHandler)) #Set Orca+PageUp key combination with increase volume function #Add decrease volume info decreasevolumeHandler = orca.input_event.InputEventHandler( decreasevolume, "Decreases master volume by 3 steps, and speaks the new value") # Shows the function of the key press in learn mode myKeyBindings.add(orca.keybindings.KeyBinding( "Page_Down", orca.settings.ORCA_MODIFIER_MASK, orca.settings.ORCA_MODIFIER_MASK, decreasevolumeHandler)) #Set Orca+PageDown key combination with decrease volume function #Add toggle mute volume info mutevolumeHandler = orca.input_event.InputEventHandler( togglevolumemute, "Toggles master volume mute on/off") # Shows the function of the key press in learn mode myKeyBindings.add(orca.keybindings.KeyBinding( "End", orca.settings.ORCA_MODIFIER_MASK, orca.settings.ORCA_MODIFIER_MASK, mutevolumeHandler)) #Set Orca+End key combination with toggle volume mute function orca.settings.keyBindingsMap["default"] = myKeyBindings #end time, date, and weather code