From d66d60ee496b84ce73858a33a2ac511d2275486e Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Fri, 20 Dec 2024 06:47:55 -0500 Subject: [PATCH] Added ability to toggle between Cthulhu and Orca with RP Mode - shift+T. --- i38.sh | 8 ++++-- scripts/toggle_screenreader.sh | 47 ++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 2 deletions(-) create mode 100755 scripts/toggle_screenreader.sh diff --git a/i38.sh b/i38.sh index 71d5bc6..d43e1f0 100755 --- a/i38.sh +++ b/i38.sh @@ -641,8 +641,12 @@ bindsym Mod1+b exec --no-startup-id ${i3Path}/scripts/battery_status.sh, mode "d bindsym g exec ${i3Path}/scripts/game_controler.sh -s, mode "default" # Get a list of windows in the current workspace bindsym apostrophe exec --no-startup-id ${i3Path}/scripts/window_list.sh, mode "default" -# Restart $screenReader -bindsym Shift+o exec $screenReader --replace, mode "default" +# Restart Cthulhu +bindsym Shift+c exec $(command -v cthulhu) --replace, mode "default" +# Restart Orca +bindsym Shift+o exec $(command -v orca) --replace, mode "default" +# Toggle screen reader +bindsym Shift+t exec ${i3Path}/scripts/toggle_screenreader.sh, mode "default" $(if [[ $usingSway -eq 0 ]]; then echo "# reload the configuration file" echo "bindsym Control+semicolon exec bash -c '$i3msg -t command reload && spd-say -P important -Cw "I38 Configuration reloaded."', mode "default"" diff --git a/scripts/toggle_screenreader.sh b/scripts/toggle_screenreader.sh new file mode 100755 index 0000000..ed5fb5e --- /dev/null +++ b/scripts/toggle_screenreader.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +# This file is part of I38. + +# I38 is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, +# either version 3 of the License, or (at your option) any later version. + +# I38 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License along with I38. If not, see . + +#!/bin/bash + +# Function to check if a process is running +is_running() { + pgrep -x "$1" >/dev/null + return $? +} + +# Speak messages +speak() { + spd-say -P important -Cw -- "$*" +} + +# Make sure both screen readers are available +for i in $(command -v cthulhu 2> /dev/null) $(command -v orca 2> /dev/null) ; do + if ! command -v "$i" &> /dev/null ; then + speak "${i##*/} not found, cannot switch to it." + exit 1 + fi +done + +# Toggle between screen readers +if is_running "cthulhu"; then + speak "Switching from Cthulhu to Orca..." + pkill -15 cthulhu + sleep .5 + command orca & +elif is_running "orca"; then + speak "Switching from Orca to Cthulhu..." + pkill -15 orca + sleep .5 + command cthulhu & +fi + +exit 0