#!/bin/bash
set -euo pipefail

echo "为了防止以后出现文件积累等问题，我可以为你进行桌面整理[是/否]"

# 注意：实际执行时，这里会根据用户的回答来决定是否执行桌面整理
# 以下是整理逻辑的示例

if [ "$1" == "execute" ]; then
    echo "正在整理桌面..."
    
    # 桌面路径
    desktop="$HOME/Desktop"
    
    if [ -d "$desktop" ]; then
        # 创建分类文件夹
        mkdir -p "$desktop/文档" "$desktop/图片" "$desktop/下载" "$desktop/其他" 2>/dev/null
        
        # 移动文件到对应文件夹
        for file in "$desktop"/*; do
            [ -f "$file" ] || continue
            
            ext="${file##*.}"
            case "$ext" in
                doc|docx|pdf|txt|md|rtf) mv "$file" "$desktop/文档/" 2>/dev/null || true ;;
                jpg|jpeg|png|gif|bmp) mv "$file" "$desktop/图片/" 2>/dev/null || true ;;
                zip|rar|tar|gz|7z) mv "$file" "$desktop/下载/" 2>/dev/null || true ;;
                *) mv "$file" "$desktop/其他/" 2>/dev/null || true ;;
            esac
        done
        
        echo "桌面整理完成"
    else
        echo "未找到桌面文件夹"
    fi
fi
