[orca-list] orca-customizations.py
- From: chrys87 <chrys87 web de>
- To: orca-list gnome org
- Subject: [orca-list] orca-customizations.py
- Date: Fri, 20 Sep 2013 07:01:51 +0200
Hi out there,
I made (based on the gnome wiki) a orca-customizations.py
Wiki code wont work for me. I think its outdated.
I share it with the list. maybe someone need this funktionality or need
a working demo.
the script can read the battery status (orca + a) and the content of the
clippboard (orca + r).
This works for me with fedora 19.
Here the script:
# Say Clipboard (Orca + r)
# Say Battery (Orca + a)
# for Orca Screenreader
# Version: 0.2
#Python
from __future__ import division
#GTK/GDK
from gi.repository import Gtk, Gdk
# Orca
import orca.braille
import orca.input_event
import orca.keybindings
import orca.orca
import orca.speech
myKeyBindings = orca.keybindings.KeyBindings()
#Say Clipboard-------------------------------
def sayClipboard(script, inputEvent=None):
Message = "Zwischenablage "
# Get Clipboard
ClipboardObj = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
ClipboardText = ClipboardObj.wait_for_text()
if (ClipboardText != None):
Message = Message + ClipboardText
else:
Message = + "ist leer"
# Say/braille something.
orca.speech.speak(Message)
#orca.braille.displayMessage(Message)
# Consume the event so it will not go to an application.
return True
sayClipboardHandler = orca.input_event.InputEventHandler(
sayClipboard, "Spreche Inhalt der Zwischenabglage")
# Shortcut Orca + a
myKeyBindings.add(orca.keybindings.KeyBinding(
"r",
1 << orca.settings.MODIFIER_ORCA,
1 << orca.settings.MODIFIER_ORCA,
sayClipboardHandler))
#Say Clipboard++++++++++++++++++++++++++++++
#Say Battery State-----------------------------------
def sayBatteryStatus(script, inputEvent=None):
try:
BatteryStatus = open("/sys/class/power_supply/BAT1/status", "r")
Status = BatteryStatus.read()
BatteryStatus.close()
Message = Status
if Status.find("Full") == 0:
# Battery is Full
Message = "Akku ist voll geladen"
else:
BatteryFull =
open("/sys/class/power_supply/BAT1/charge_full", "r")
Full = int( BatteryFull.read())
BatteryFull.close()
BatteryCurrent =
open("/sys/class/power_supply/BAT1/charge_now", "r")
Current = int( BatteryCurrent.read())
if Status.find("Charging") == 0:
# Label for Battery Charging
Status = "Lade "
if Status.find("Discharging") == 0:
# Label for Battery Discharging
Status = "Entlade "
Percent = int( Current / Full * 100)
# Charging/Discharging XX Percent
Message = Status + str( Percent) + " Prozent"
#print Message #Debugging
#print Percent #Debugging
#print Status #Debugging
except IOError:
# Battery not found or cant open.
Message = "Batterie nicht gefunden oder kann nicht geoeffnent
werden."
orca.speech.speak(Message)
#orca.braille.displayMessage(Message)
# Consume the event so it will not go to an application.
return True
sayBatteryStatusHandler = orca.input_event.InputEventHandler(
sayBatteryStatus, "Spreche den Status des Akkus")
# Shortcut Orca + a
myKeyBindings.add(orca.keybindings.KeyBinding(
"a",
1 << orca.settings.MODIFIER_ORCA,
1 << orca.settings.MODIFIER_ORCA,
sayBatteryStatusHandler))
#Say Battery State+++++++++++++++++++++++++++++++++++
orca.settings.keyBindingsMap["default"] = myKeyBindings
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]