1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 12:41:46 +00:00

Christmas eggs

This commit is contained in:
Tw93
2025-12-10 10:27:45 +08:00
parent 198591289f
commit def494b282
4 changed files with 134 additions and 17 deletions

Binary file not shown.

View File

@@ -5,6 +5,7 @@ import (
"sort"
"strconv"
"strings"
"time"
"github.com/charmbracelet/lipgloss"
)
@@ -16,6 +17,7 @@ var (
dangerStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#FF6B6B")).Bold(true)
okStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#87D787"))
lineStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#5A5A5A"))
hatStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#FF0000"))
)
const (
@@ -30,6 +32,14 @@ const (
iconProcs = "▶"
)
// Check if it's Christmas season (Dec 10-31)
func isChristmasSeason() bool {
now := time.Now()
month := now.Month()
day := now.Day()
return month == time.December && day >= 10 && day <= 31
}
// Mole body frames (legs animate)
var moleBody = [][]string{
{
@@ -58,10 +68,55 @@ var moleBody = [][]string{
},
}
// Mole body frames with Christmas hat
var moleBodyWithHat = [][]string{
{
` *`,
` /o\`,
` {/\_/\}`,
` ___/ o o \`,
` /___ =-= /`,
` \____)-m-m)`,
},
{
` *`,
` /o\`,
` {/\_/\}`,
` ___/ o o \`,
` /___ =-= /`,
` \____)mm__)`,
},
{
` *`,
` /o\`,
` {/\_/\}`,
` ___/ · · \`,
` /___ =-= /`,
` \___)-m__m)`,
},
{
` *`,
` /o\`,
` {/\_/\}`,
` ___/ o o \`,
` /___ =-= /`,
` \____)-mm-)`,
},
}
// Generate frames with horizontal movement
func getMoleFrame(animFrame int, termWidth int) string {
bodyIdx := animFrame % len(moleBody)
body := moleBody[bodyIdx]
var body []string
var bodyIdx int
isChristmas := isChristmasSeason()
if isChristmas {
bodyIdx = animFrame % len(moleBodyWithHat)
body = moleBodyWithHat[bodyIdx]
} else {
bodyIdx = animFrame % len(moleBody)
body = moleBody[bodyIdx]
}
// Calculate mole width (approximate)
moleWidth := 15
@@ -83,9 +138,22 @@ func getMoleFrame(animFrame int, termWidth int) string {
padding := strings.Repeat(" ", pos)
var lines []string
for _, line := range body {
lines = append(lines, padding+line)
if isChristmas {
// Render with red hat on first 3 lines
for i, line := range body {
if i < 3 {
lines = append(lines, padding+hatStyle.Render(line))
} else {
lines = append(lines, padding+line)
}
}
} else {
for _, line := range body {
lines = append(lines, padding+line)
}
}
return strings.Join(lines, "\n")
}

View File

@@ -53,6 +53,21 @@ readonly MOLE_CRASH_REPORT_AGE_DAYS=7 # Crash report retention
readonly MOLE_SAVED_STATE_AGE_DAYS=7 # App saved state retention
readonly MOLE_TM_BACKUP_SAFE_HOURS=48 # Time Machine failed backup safety window
# ============================================================================
# Seasonal Functions
# ============================================================================
is_christmas_season() {
local month day
month=$(date +%-m)
day=$(date +%-d)
# December 10 to December 31
if [[ $month -eq 12 && $day -ge 10 && $day -le 31 ]]; then
return 0
fi
return 1
}
# ============================================================================
# Whitelist Configuration
# ============================================================================

60
mole
View File

@@ -22,7 +22,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/lib/core/common.sh"
# Version info
VERSION="1.12.1"
VERSION="1.12.3"
MOLE_TAGLINE="can dig deep to clean your Mac."
# Check if Touch ID is already configured
@@ -114,9 +114,25 @@ animate_mole_intro() {
hide_cursor
local -a mole_lines=()
while IFS= read -r line; do
mole_lines+=("$line")
done << 'EOF'
if is_christmas_season; then
while IFS= read -r line; do
mole_lines+=("$line")
done << 'EOF'
*
/o\
{/\_/\}
____/ o o \
/~____ =o= /
(______)__m_m)
/ \
__/ /\ \__
/__/ \__\_
EOF
else
while IFS= read -r line; do
mole_lines+=("$line")
done << 'EOF'
/\_/\
____/ o o \
/~____ =o= /
@@ -125,19 +141,37 @@ animate_mole_intro() {
__/ /\ \__
/__/ \__\_
EOF
fi
local idx
local body_cutoff=4
local hat_color="${RED}"
local body_cutoff
local body_color="${PURPLE}"
local ground_color="${GREEN}"
for idx in "${!mole_lines[@]}"; do
if ((idx < body_cutoff)); then
printf "%s\n" "${body_color}${mole_lines[$idx]}${NC}"
else
printf "%s\n" "${ground_color}${mole_lines[$idx]}${NC}"
fi
sleep 0.1
done
if is_christmas_season; then
body_cutoff=6
for idx in "${!mole_lines[@]}"; do
if ((idx < 3)); then
printf "%s\n" "${hat_color}${mole_lines[$idx]}${NC}"
elif ((idx < body_cutoff)); then
printf "%s\n" "${body_color}${mole_lines[$idx]}${NC}"
else
printf "%s\n" "${ground_color}${mole_lines[$idx]}${NC}"
fi
sleep 0.1
done
else
body_cutoff=4
for idx in "${!mole_lines[@]}"; do
if ((idx < body_cutoff)); then
printf "%s\n" "${body_color}${mole_lines[$idx]}${NC}"
else
printf "%s\n" "${ground_color}${mole_lines[$idx]}${NC}"
fi
sleep 0.1
done
fi
printf '\n'
sleep 0.5