Enhanced prompt detection

This commit is contained in:
Storm Dragon 2025-06-08 13:31:37 -04:00
parent ca0e3b5987
commit 6ad11effc6
4 changed files with 63 additions and 5 deletions

View File

@ -218,16 +218,24 @@ quickMenu=speech#rate;speech#pitch;speech#volume
# Custom prompt patterns for silence until prompt feature
# You can add your own shell prompt patterns as regular expressions
# Each pattern should be on a separate line, format: customPatterns=pattern1,pattern2,pattern3
# Examples:
#
# Built-in patterns include:
# - Shell prompts: $, #, >, user@host$, [user@host]$, bash-5.1$
# - Package manager prompts: [Y/n], [y/N], [Yes/No], (Y/n), (y/N)
# - sudo prompts: [sudo] password for user:, Password:, user's password:
# - Confirmation prompts: Press any key, Are you sure?, Please confirm
#
# Custom pattern examples:
# For PS1='[\u@\h \W] \$ ' use: \[.*@.*\s.*\]\s*[$#>]\s*
# For "[user@hostname ~] $" use: \[.*@.*\s.*\]\s*[$#>]\s*
# For custom prompts ending with specific strings, use patterns like: .*your_prompt_ending$
# For custom package manager prompts: .*your_package_manager.*\[[YyNn]/[YyNn]\].*
customPatterns=
# Specific prompt strings to match exactly (useful for very specific custom prompts)
# Format: exactMatches=prompt1,prompt2,prompt3
# Examples:
# exactMatches=[storm@fenrir ~] $,[root@fenrir ~] #
# exactMatches=[storm@fenrir ~] $,[root@fenrir ~] #,Continue installation? [Y/n]
exactMatches=
[time]

View File

@ -74,12 +74,37 @@ class command():
# Add default shell prompt patterns
promptPatterns.extend([
r'^\s*\\\$\s*$', # Just $ (with whitespace)
r'^\s*\$\s*$', # Just $ (with whitespace)
r'^\s*#\s*$', # Just # (with whitespace)
r'^\s*>\s*$', # Just > (with whitespace)
r'.*@.*[\\\$#>]\s*$', # Contains @ and ends with prompt char (user@host style)
r'^\[.*\]\s*[\\\$#>]\s*$', # [anything]$ style prompts
r'^[a-zA-Z0-9._-]+[\\\$#>]\s*$', # Simple shell names like bash-5.1$
# Interactive prompt patterns
# Package manager confirmation prompts
r'.*\?\s*\[[YyNn]/[YyNn]\]\s*$', # ? [Y/n] or ? [y/N] style
r'.*\?\s*\[[Yy]es/[Nn]o\]\s*$', # ? [Yes/No] style
r'.*\?\s*\([YyNn]/[YyNn]\)\s*$', # ? (Y/n) or ? (y/N) style
r'.*\?\s*\([Yy]es/[Nn]o\)\s*$', # ? (Yes/No) style
r'.*continue\?\s*\[[YyNn]/[YyNn]\].*$', # "continue? [Y/n]" style
r'.*ok\s*\[[YyNn]/[YyNn]\].*$', # "Is this ok [y/N]:" style
r'^::.*\?\s*\[[YyNn]/[YyNn]\].*$', # pacman ":: Proceed? [Y/n]" style
# Authentication prompts
r'^\[[Ss]udo\]\s*[Pp]assword\s*for\s+.*:\s*$', # [sudo] password for user:
r'^[Pp]assword\s*:\s*$', # Password:
r'.*[Pp]assword\s*:\s*$', # general password prompts
r".*'s\s*[Pp]assword\s*:\s*$", # user's password:
r'^[Ee]nter\s+[Pp]assphrase.*:\s*$', # Enter passphrase:
r'^[Pp]lease\s+enter\s+[Pp]assphrase.*:\s*$', # Please enter passphrase:
# General confirmation and continuation prompts
r'^[Pp]ress\s+any\s+key\s+to\s+continue.*$', # Press any key to continue
r'^[Aa]re\s+you\s+sure\?\s*.*$', # Are you sure?
r'^[Pp]lease\s+confirm.*$', # Please confirm
r'.*confirm.*\([YyNn]/[YyNn]\).*$', # confirm (y/n)
r'.*\([Yy]/[Nn]\)\s*$', # ends with (Y/n) or (y/N)
])
for pattern in promptPatterns:

View File

@ -68,12 +68,37 @@ class command():
# Add default shell prompt patterns
promptPatterns.extend([
r'^\s*\\\$\s*$', # Just $ (with whitespace)
r'^\s*\$\s*$', # Just $ (with whitespace)
r'^\s*#\s*$', # Just # (with whitespace)
r'^\s*>\s*$', # Just > (with whitespace)
r'.*@.*[\\\$#>]\s*$', # Contains @ and ends with prompt char (user@host style)
r'^\[.*\]\s*[\\\$#>]\s*$', # [anything]$ style prompts
r'^[a-zA-Z0-9._-]+[\\\$#>]\s*$', # Simple shell names like bash-5.1$
# Interactive prompt patterns
# Package manager confirmation prompts
r'.*\?\s*\[[YyNn]/[YyNn]\]\s*$', # ? [Y/n] or ? [y/N] style
r'.*\?\s*\[[Yy]es/[Nn]o\]\s*$', # ? [Yes/No] style
r'.*\?\s*\([YyNn]/[YyNn]\)\s*$', # ? (Y/n) or ? (y/N) style
r'.*\?\s*\([Yy]es/[Nn]o\)\s*$', # ? (Yes/No) style
r'.*continue\?\s*\[[YyNn]/[YyNn]\].*$', # "continue? [Y/n]" style
r'.*ok\s*\[[YyNn]/[YyNn]\].*$', # "Is this ok [y/N]:" style
r'^::.*\?\s*\[[YyNn]/[YyNn]\].*$', # pacman ":: Proceed? [Y/n]" style
# Authentication prompts
r'^\[[Ss]udo\]\s*[Pp]assword\s*for\s+.*:\s*$', # [sudo] password for user:
r'^[Pp]assword\s*:\s*$', # Password:
r'.*[Pp]assword\s*:\s*$', # general password prompts
r".*'s\s*[Pp]assword\s*:\s*$", # user's password:
r'^[Ee]nter\s+[Pp]assphrase.*:\s*$', # Enter passphrase:
r'^[Pp]lease\s+enter\s+[Pp]assphrase.*:\s*$', # Please enter passphrase:
# General confirmation and continuation prompts
r'^[Pp]ress\s+any\s+key\s+to\s+continue.*$', # Press any key to continue
r'^[Aa]re\s+you\s+sure\?\s*.*$', # Are you sure?
r'^[Pp]lease\s+confirm.*$', # Please confirm
r'.*confirm.*\([YyNn]/[YyNn]\).*$', # confirm (y/n)
r'.*\([Yy]/[Nn]\)\s*$', # ends with (Y/n) or (y/N)
])
for pattern in promptPatterns:

View File

@ -4,5 +4,5 @@
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
version = "2025.06.07"
version = "2025.06.08"
codeName = "testing"