mirror of
https://github.com/tw93/Mole.git
synced 2026-02-16 18:10:17 +00:00
Improve sudo prompt interaction with safe line clearing for a cleaner UI
This commit is contained in:
@@ -116,15 +116,23 @@ request_sudo_access() {
|
|||||||
# Check if in clamshell mode - if yes, skip Touch ID entirely
|
# Check if in clamshell mode - if yes, skip Touch ID entirely
|
||||||
if is_clamshell_mode; then
|
if is_clamshell_mode; then
|
||||||
echo -e "${PURPLE}${ICON_ARROW}${NC} ${prompt_msg}"
|
echo -e "${PURPLE}${ICON_ARROW}${NC} ${prompt_msg}"
|
||||||
_request_password "$tty_path"
|
if _request_password "$tty_path"; then
|
||||||
return $?
|
# Clear all prompt lines (use safe clearing method)
|
||||||
|
safe_clear_lines 3 "$tty_path"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Not in clamshell mode - try Touch ID if configured
|
# Not in clamshell mode - try Touch ID if configured
|
||||||
if ! check_touchid_support; then
|
if ! check_touchid_support; then
|
||||||
echo -e "${PURPLE}${ICON_ARROW}${NC} ${prompt_msg}"
|
echo -e "${PURPLE}${ICON_ARROW}${NC} ${prompt_msg}"
|
||||||
_request_password "$tty_path"
|
if _request_password "$tty_path"; then
|
||||||
return $?
|
# Clear all prompt lines (use safe clearing method)
|
||||||
|
safe_clear_lines 3 "$tty_path"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Touch ID is available and not in clamshell mode
|
# Touch ID is available and not in clamshell mode
|
||||||
@@ -143,7 +151,8 @@ request_sudo_access() {
|
|||||||
wait "$sudo_pid" 2> /dev/null
|
wait "$sudo_pid" 2> /dev/null
|
||||||
local exit_code=$?
|
local exit_code=$?
|
||||||
if [[ $exit_code -eq 0 ]] && sudo -n true 2> /dev/null; then
|
if [[ $exit_code -eq 0 ]] && sudo -n true 2> /dev/null; then
|
||||||
# Touch ID succeeded
|
# Touch ID succeeded - clear the prompt line
|
||||||
|
safe_clear_lines 1 "$tty_path"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
# Touch ID failed or cancelled
|
# Touch ID failed or cancelled
|
||||||
@@ -169,10 +178,15 @@ request_sudo_access() {
|
|||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
# Clear any leftover prompts on the screen
|
# Clear any leftover prompts on the screen
|
||||||
printf "\r\033[2K" > "$tty_path"
|
safe_clear_line "$tty_path"
|
||||||
|
|
||||||
# Now use our password input (this should not trigger Touch ID again)
|
# Now use our password input (this should not trigger Touch ID again)
|
||||||
_request_password "$tty_path"
|
if _request_password "$tty_path"; then
|
||||||
|
# Clear all prompt lines (use safe clearing method)
|
||||||
|
safe_clear_lines 3 "$tty_path"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user