"""This script adds battery status, date, time, and weather functionality to Orca Time or date can be pasted from the clipboard Adapted by Storm Dragon from the script posted at: http://live.gnome.org/Orca/FrequentlyAskedQuestions#head-6a8c1c2511ba01d7397f68f754eec0d923d166f1 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 #change the next line to your zip code: zipCode = 0 #places text in the clipboard def setClipboardText(text): import gtk # import the gtk library cb = gtk.Clipboard() cb.set_text(text) cb.store() #getWeather function gets weather from Yahoo def getWeather(zip_code): if zip_code != 0: import urllib from xml.dom import minidom WEATHER_URL = 'http://xml.weather.yahoo.com/forecastrss?p=%s' WEATHER_NS = 'http://xml.weather.yahoo.com/ns/rss/1.0' url = WEATHER_URL % zip_code dom = minidom.parse(urllib.urlopen(url)) ycondition = dom.getElementsByTagNameNS(WEATHER_NS, 'condition')[0] weatherReport = ycondition.getAttribute('temp') + ' | ' + ycondition.getAttribute('text') else: weatherReport = "No zip code set: Please edit .orca/orca-customizations.py" return weatherReport myKeyBindings = orca.keybindings.KeyBindings() #define the battery status function def sayBattery(script, inputEvent=None): import commands message = commands.getoutput("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 sayTime function def sayTime(script, inputEvent=None): import time # imports the Python time library 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): import time # imports the Python time library 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 sayWeather function def sayWeather(script, inputEvent=None): message = getWeather(zipCode) orca.speech.speak(message) orca.braille.displayMessage(message) return True #end sayWeather 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 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 Orca-t as 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( "d", 1 << orca.settings.MODIFIER_ORCA, 1 << orca.settings.MODIFIER_ORCA, sayDateHandler)) # Sets Orca-d as the say date 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 Orca-d as the say date key orca.settings.keyBindingsMap["default"] = myKeyBindings #end time, date, and weather code