Added title reader so that Doom will announce the level name when it starts.

This commit is contained in:
stormdragon2976 2023-05-07 17:49:01 -04:00
parent ab9363dd73
commit 6776479857
2 changed files with 30 additions and 0 deletions

View File

@ -404,6 +404,7 @@ game_launcher() {
fi
;;
*doom*)
${0%/*}/speech/speak_window_title.sh gzdoom &
exec ${game}
;;
*"main.py")

29
speech/speak_window_title.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
# Adapted from the bash snippet found at:
# https://bbs.archlinux.org/viewtopic.php?id=117031
# Wait for the application to start
while ! pgrep -u "$USER" ^$1 &> /dev/null ; do
sleep 0.05
done
# Read so long as the application is running
while pgrep -u "$USER" ^$1 &> /dev/null ; do
sleep 0.05
if [[ -f ~/.agmsilent ]]; then
continue
fi
wnd_focus=$(xdotool getwindowfocus)
wnd_title=$(xprop -id $wnd_focus WM_NAME)
lookfor='"(.*)"'
if [[ "$wnd_title" =~ $lookfor ]]; then
wnd_title=${BASH_REMATCH[1]}
if [[ "$old_title" != "$wnd_title" ]]; then
spd-say -- "$wnd_title"
old_title="$wnd_title"
fi
fi
done
exit 0