1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-11 01:19:16 +00:00

Menu effect optimization

This commit is contained in:
Tw93
2025-11-22 13:32:19 +08:00
parent 0744e41941
commit df66b69329
2 changed files with 27 additions and 1 deletions

View File

@@ -288,6 +288,8 @@ read_key() {
'q' | 'Q') echo "QUIT" ;; 'q' | 'Q') echo "QUIT" ;;
'h' | 'H') echo "HELP" ;; 'h' | 'H') echo "HELP" ;;
'v' | 'V') echo "VERSION" ;; 'v' | 'V') echo "VERSION" ;;
't' | 'T') echo "TOUCHID" ;;
'u' | 'U') echo "UPDATE" ;;
'R') echo "RETRY" ;; 'R') echo "RETRY" ;;
'o' | 'O') echo "OPEN" ;; 'o' | 'O') echo "OPEN" ;;
'/') echo "FILTER" ;; '/') echo "FILTER" ;;

26
mole
View File

@@ -25,6 +25,12 @@ source "$SCRIPT_DIR/lib/common.sh"
VERSION="1.10.1" VERSION="1.10.1"
MOLE_TAGLINE="can dig deep to clean your Mac." MOLE_TAGLINE="can dig deep to clean your Mac."
# Check if Touch ID is already configured
is_touchid_configured() {
local pam_sudo_file="/etc/pam.d/sudo"
[[ -f "$pam_sudo_file" ]] && grep -q "pam_tid.so" "$pam_sudo_file" 2> /dev/null
}
# Get latest version from remote repository # Get latest version from remote repository
get_latest_version() { get_latest_version() {
curl -fsSL --connect-timeout 2 --max-time 3 -H "Cache-Control: no-cache" \ curl -fsSL --connect-timeout 2 --max-time 3 -H "Cache-Control: no-cache" \
@@ -508,7 +514,15 @@ show_main_menu() {
if [[ -t 0 ]]; then if [[ -t 0 ]]; then
printf '\r\033[2K\n' printf '\r\033[2K\n'
printf '\r\033[2K%s\n' "${GRAY}↑↓ | Enter | H Help | V Version | Q Quit${NC}" # Show TouchID if not configured, otherwise show Update
local controls="${GRAY}↑↓ | Enter | H Help | "
if ! is_touchid_configured; then
controls="${controls}T TouchID"
else
controls="${controls}U Update"
fi
controls="${controls} | Q Quit${NC}"
printf '\r\033[2K%s\n' "$controls"
printf '\r\033[2K\n' printf '\r\033[2K\n'
fi fi
@@ -611,6 +625,16 @@ interactive_main_menu() {
show_version show_version
exit 0 exit 0
;; ;;
"TOUCHID")
show_cursor
exec "$SCRIPT_DIR/bin/touchid.sh"
;;
"UPDATE")
show_cursor
clear
update_mole
exit 0
;;
"QUIT") cleanup_and_exit ;; "QUIT") cleanup_and_exit ;;
esac esac