| 1 |
#!/usr/bin/env python3 |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
|
| 4 |
# Fenrir TTY screen reader |
| 5 |
# By Chrys, Storm Dragon, and contributors. |
| 6 |
|
| 7 |
import time |
| 8 |
|
| 9 |
from fenrirscreenreader.core.i18n import _ |
| 10 |
|
| 11 |
|
| 12 |
class command: |
| 13 |
def __init__(self): |
| 14 |
pass |
| 15 |
|
| 16 |
def initialize(self, environment): |
| 17 |
self.env = environment |
| 18 |
self.last_time = time.time() |
| 19 |
|
| 20 |
def shutdown(self): |
| 21 |
pass |
| 22 |
|
| 23 |
def get_description(self): |
| 24 |
return "No description found" |
| 25 |
|
| 26 |
def run(self): |
| 27 |
play_sound = False |
| 28 |
device_list = self.env["runtime"][ |
| 29 |
"InputManager" |
| 30 |
].get_last_detected_devices() |
| 31 |
try: |
| 32 |
for deviceEntry in device_list: |
| 33 |
# dont play sounds for virtual devices |
| 34 |
play_sound = play_sound or not deviceEntry["virtual"] |
| 35 |
except Exception as e: |
| 36 |
play_sound = True |
| 37 |
if play_sound: |
| 38 |
if time.time() - self.last_time > 5: |
| 39 |
self.env["runtime"]["OutputManager"].play_sound_icon( |
| 40 |
sound_icon="accept", interrupt=True |
| 41 |
) |
| 42 |
last_time = time.time() |
| 43 |
|
| 44 |
def set_callback(self, callback): |
| 45 |
pass |