desktop-fix改为白名单模式,目前只有KDE

This commit is contained in:
2026-05-06 22:53:24 +08:00
parent b7d4e07105
commit d5bb8f929c

View File

@@ -1,32 +1,18 @@
#!/bin/bash #!/bin/bash
# 检测是否安装了 XFCE、DDE 或 GNOME 桌面环境 # 检测是否安装了 KDE Plasma 桌面环境
# 通过检查系统中是否存在相关的 desktop 文件或关键程序 # 通过检查系统中是否存在相关的 desktop 文件或关键程序
is_xfce_or_dde_or_gnome() { is_kde_plasma() {
# 检查 XFCE # 检查 KDE Plasma
if [ -f /usr/share/xsessions/xfce.desktop ] || \ if [ -f /usr/share/xsessions/plasma.desktop ] || \
[ -f /usr/local/share/xsessions/xfce.desktop ] || \ [ -f /usr/share/xsessions/plasma-xorg.desktop ] || \
command -v xfce4-session >/dev/null 2>&1; then [ -f /usr/share/xsessions/plasma-wayland.desktop ] || \
return 0 [ -f /usr/local/share/xsessions/plasma.desktop ] || \
fi [ -f /usr/local/share/xsessions/plasma-xorg.desktop ] || \
# 检查 DDE/Deepin [ -f /usr/local/share/xsessions/plasma-wayland.desktop ] || \
if [ -f /usr/share/xsessions/deepin.desktop ] || \ command -v startplasma-x11 >/dev/null 2>&1 || \
[ -f /usr/share/xsessions/dde.desktop ] || \ command -v startplasma-wayland >/dev/null 2>&1 || \
[ -f /usr/local/share/xsessions/deepin.desktop ] || \ command -v plasmashell >/dev/null 2>&1; then
[ -f /usr/local/share/xsessions/dde.desktop ] || \
command -v dde-session >/dev/null 2>&1 || \
command -v startdde >/dev/null 2>&1; then
return 0
fi
# 检查 GNOME
if [ -f /usr/share/xsessions/gnome.desktop ] || \
[ -f /usr/share/xsessions/gnome-xorg.desktop ] || \
[ -f /usr/share/xsessions/gnome-wayland.desktop ] || \
[ -f /usr/local/share/xsessions/gnome.desktop ] || \
[ -f /usr/local/share/xsessions/gnome-xorg.desktop ] || \
[ -f /usr/local/share/xsessions/gnome-wayland.desktop ] || \
command -v gnome-session >/dev/null 2>&1 || \
command -v gnome-shell >/dev/null 2>&1; then
return 0 return 0
fi fi
return 1 return 1
@@ -39,13 +25,13 @@ if grep -q "Kylin" /etc/os-release; then
echo "检测到麒麟系统,使用目标目录: $TARGET_BASE" echo "检测到麒麟系统,使用目标目录: $TARGET_BASE"
else else
TARGET_BASE="/usr/local/share" TARGET_BASE="/usr/local/share"
# 检测是否为 XFCE、DDE 或 GNOME 桌面环境 # 检测是否为 KDE Plasma 桌面环境
if is_xfce_or_dde_or_gnome; then if is_kde_plasma; then
APP_TARGET_DIR="$TARGET_BASE/applications"
echo "检测到 XFCE/DDE/GNOME 桌面环境,使用目标目录: $APP_TARGET_DIR"
else
APP_TARGET_DIR="$TARGET_BASE/applications/apm" APP_TARGET_DIR="$TARGET_BASE/applications/apm"
echo "使用目标目录: $APP_TARGET_DIR" echo "检测到 KDE Plasma 桌面环境,使用目标目录: $APP_TARGET_DIR"
else
APP_TARGET_DIR="$TARGET_BASE/applications"
echo "使用标准目标目录: $APP_TARGET_DIR"
fi fi
fi fi
@@ -142,5 +128,4 @@ if ! grep -q "Kylin" /etc/os-release; then
rmdir "$APM_SUBDIR" 2>/dev/null || true rmdir "$APM_SUBDIR" 2>/dev/null || true
fi fi
fi fi
fi fi