#!/bin/bash
# Xfce桌面美化一键脚本 (2025-05-01)
# 支持功能：GTK主题/窗口主题/图标主题/字体/壁纸/附加组件

# 1. 系统准备
sudo apt update && sudo apt install -y \
    git wget tar zsh build-essential \
    gtk-engine-murrine gtk2-engines \
    xfce4-goodies plank vala-panel-appmenu

# 2. 下载并安装主题资源
THEME_DIR="/usr/share/themes"
ICONS_DIR="/usr/share/icons"
mkdir -p $THEME_DIR$ICONS_DIR

# 2.1 GTK主题安装
wget https://github.com/vinceliuice/Colloid-gtk-theme/archive/refs/tags/v1.5.2.tar.gz -O colloid.tar.gz
sudo tar -xzf colloid.tar.gz -C $THEME_DIR --strip-components=1 --wildcards '*gtk-3.0'
rm colloid.tar.gz

# 2.2 窗口管理器主题
wget https://github.com/vinceliuice/WhiteSur-gtk-theme/archive/refs/tags/3.4.0.tar.gz -O whitesur.tar.gz
sudo tar -xzf whitesur.tar.gz -C $THEME_DIR --strip-components=1 --wildcards '*xfwm4'
rm whitesur.tar.gz

# 2.3 图标主题
wget https://github.com/vinceliuice/WhiteSur-icon-theme/archive/refs/tags/1.0.2.tar.gz -O whitesur-icons.tar.gz
sudo tar -xzf whitesur-icons.tar.gz -C $ICONS_DIR --strip-components=1
rm whitesur-icons.tar.gz

# 3. 配置主题参数
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/workspace0/last-image -s "/usr/share/backgrounds/xfce/xfce-blue.jpg"
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/workspace0/image-style -s 2

xfconf-query -c xsettings -p /Net/ThemeName -s "WhiteSur-dark"
xfconf-query -c xsettings -p /Net/IconThemeName -s "WhiteSur"
xfconf-query -c xfwm4 -p /general/theme -s "WhiteSur"

# 4. 字体优化
sudo apt install -y ttf-wqy-zenhei ttf-opensans ttf-dejavu
fc-cache -fv

# 5. macOS风格增强
mkdir -p ~/.config/xfce4/xfconf/xfce-perchannel-xml
wget https://raw.githubusercontent.com/numixproject/numix-wallpapers/master/Numix-Dark.jpg -O ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml

# 6. 面板配置
plank & disown
vala-panel-appmenu --install

# 7. 重启服务
xfce4-panel -r
killall xfwm4 && xfwm4 --replace &

echo "美化完成！建议重启系统以完全应用配置"
echo "当前主题配置："
echo "GTK主题: WhiteSur-Dark"
echo "窗口主题: WhiteSur"
echo "图标主题: WhiteSur"
echo "壁纸路径: /usr/share/backgrounds/xfce/xfce-blue.jpg"