AIA 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #!/usr/bin/python3
  2. # this file is part from AIA
  3. # AIA is free software: you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation, either version 3 of the License, or
  6. # (at your option) any later version.
  7. # AIA is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. # You should have received a copy of the GNU General Public License
  12. import os
  13. import gi
  14. import xapp.os
  15. import gettext
  16. import signal
  17. from gi.repository import Gtk
  18. try:
  19. gi.require_version('AyatanaAppIndicator3', '0.1')
  20. from gi.repository import AyatanaAppIndicator3 as appindicator
  21. except ValueError:
  22. gi.require_version('AppIndicator3', '0.1')
  23. from gi.repository import AppIndicator3 as appindicator
  24. from gi.repository import GLib
  25. gettext.install("AIA", "/usr/share/AIA/locale")
  26. signal.signal(signal.SIGINT, signal.SIG_DFL)
  27. ORCA_RUN_FLAG = os.path.expanduser("/etc/xdg/autostart/orca-autostart.desktop")
  28. class AIA:
  29. def __init__(self):
  30. self.ind = appindicator.Indicator.new("new","access",appindicator.IndicatorCategory.APPLICATION_STATUS)
  31. self.ind.set_status (appindicator.IndicatorStatus.ACTIVE)
  32. self.menu = Gtk.Menu()
  33. item = Gtk.MenuItem()
  34. item.set_label(_("Start Screen Reader"))
  35. item.connect("activate", self.start)
  36. self.menu.append(item)
  37. item = Gtk.MenuItem()
  38. item.set_label(_("Stop Screen Reader"))
  39. item.connect("activate", self.stop)
  40. self.menu.append(item)
  41. item = Gtk.MenuItem()
  42. item.set_label(_("Enable Autostart Screen Reader"))
  43. item.connect("activate", self.enable_autostart)
  44. self.menu.append(item)
  45. item = Gtk.MenuItem()
  46. item.set_label(_("Disable Autostart Screen Reader"))
  47. item.connect("activate", self.disable_autostart)
  48. self.menu.append(item)
  49. item = Gtk.MenuItem()
  50. item.set_label(_("Open Accessibility Settings"))
  51. item.connect("activate", self.settings)
  52. self.menu.append(item)
  53. item = Gtk.MenuItem()
  54. item.set_label(_("On Screen Keyboard"))
  55. item.connect("activate", self.On_Screen_Keyboard)
  56. self.menu.append(item)
  57. item = Gtk.MenuItem()
  58. item.set_label(_("Exit"))
  59. item.connect("activate", self.quit)
  60. self.menu.append(item)
  61. self.menu.show_all()
  62. self.ind.set_menu(self.menu)
  63. Gtk.main()
  64. def start(self, widget):
  65. os.system("nohup orca -r > /dev/null 2>&1&")
  66. def stop(self, widget):
  67. os.system("nohup killall orca > /dev/null 2>&1&")
  68. def enable_autostart(self, widget):
  69. if (xapp.os.is_live_session()) or (xapp.os.is_guest_session()):
  70. os.system("python3 /usr/lib/AIA/Live_Session_Message.py")
  71. elif os.path.exists(ORCA_RUN_FLAG):
  72. os.system("python3 /usr/lib/AIA/Already_Running_message.py")
  73. else :
  74. os.system('usudo "cp /usr/lib/AIA/orca-autostart.desktop /etc/xdg/autostart"')
  75. def disable_autostart(self, widget):
  76. if (xapp.os.is_live_session()) or (xapp.os.is_guest_session()):
  77. os.system("python3 /usr/lib/AIA/Live_Session_Message.py")
  78. elif not os.path.exists(ORCA_RUN_FLAG):
  79. os.system("python3 /usr/lib/AIA/Already_Stop_message.py")
  80. else :
  81. os.system('usudo "rm -rf /etc/xdg/autostart/orca-autostart.desktop"')
  82. def settings(self, widget):
  83. os.system("nohup orca -s > /dev/null 2>&1&")
  84. def On_Screen_Keyboard(self, widget):
  85. os.system("nohup onboard > /dev/null 2>&1&")
  86. def quit(self, widget):
  87. Gtk.main_quit()
  88. indicator = AIA();