From 942044db92eb7335b04de1624be3433f259258de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Gon=C3=A7alves?= Date: Thu, 2 Jan 2025 13:36:15 -0300 Subject: [PATCH] Add alt+meta+S as shortcut for orca --- bigbashview/usr/lib/bbv/ui/qt.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/bigbashview/usr/lib/bbv/ui/qt.py b/bigbashview/usr/lib/bbv/ui/qt.py index f204d11..b4ba046 100644 --- a/bigbashview/usr/lib/bbv/ui/qt.py +++ b/bigbashview/usr/lib/bbv/ui/qt.py @@ -144,6 +144,10 @@ def __init__(self): self.key_f12 = QShortcut(QKeySequence(Qt.Key_F12), self.web) self.key_f12.activated.connect(self.devpage) self.web.page().profile().downloadRequested.connect(self.onDownloadRequested) + + # Meta+Alt+S Keyboard shortcut for run orca + self.key_meta_alt_s = QShortcut(QKeySequence("Meta+Alt+S"), self) + self.key_meta_alt_s.activated.connect(self.run_orca) # Set up the layout and splitter for the main window self.hbox = QHBoxLayout(self) @@ -160,6 +164,22 @@ def __init__(self): self.web.page().setWebChannel(self.channel) self.channel.registerObject("windowControl", self.control) + def run_orca(self): + try: + # Use pgrep to check if there are any running processes named 'orca' + process_check = os.system("pgrep orca > /dev/null 2>&1") + + if process_check == 0: # If pgrep returns 0, the Orca process is running + os.system("killall orca") + print("Orca process terminated.") + else: + os.system("orca &") # Start the Orca process in the background + print("Orca process started.") + except Exception as e: + # Handle any exceptions that occur while managing the Orca process + print(f"Error handling the Orca process: {e}") + + def changeEvent(self, event): super().changeEvent(event) if event.type() == QEvent.WindowStateChange: