在GNOME和GXDE上也不使用/usr/local/share/applications/apm/

This commit is contained in:
2026-04-19 18:11:29 +08:00
parent 164910091d
commit 6e8f5cd381

View File

@@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
# 检测是否安装了 XFCE 或 DDE 桌面环境 # 检测是否安装了 XFCE、DDE 或 GNOME 桌面环境
# 通过检查系统中是否存在相关的 desktop 文件或关键程序 # 通过检查系统中是否存在相关的 desktop 文件或关键程序
is_xfce_or_dde() { is_xfce_or_dde_or_gnome() {
# 检查 XFCE # 检查 XFCE
if [ -f /usr/share/xsessions/xfce.desktop ] || \ if [ -f /usr/share/xsessions/xfce.desktop ] || \
[ -f /usr/local/share/xsessions/xfce.desktop ] || \ [ -f /usr/local/share/xsessions/xfce.desktop ] || \
@@ -16,10 +16,17 @@ is_xfce_or_dde() {
[ -f /usr/local/share/xsessions/dde.desktop ] || \ [ -f /usr/local/share/xsessions/dde.desktop ] || \
command -v dde-session >/dev/null 2>&1 || \ command -v dde-session >/dev/null 2>&1 || \
command -v startdde >/dev/null 2>&1; then command -v startdde >/dev/null 2>&1; then
# 特例GXDE OS 虽然基于 DDE但使用 /apm/ 子目录 return 0
if [ -d /usr/share/gxde-api ]; then fi
return 1 # 检查 GNOME
fi 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
@@ -32,10 +39,10 @@ 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 桌面环境 # 检测是否为 XFCE、DDE 或 GNOME 桌面环境
if is_xfce_or_dde; then if is_xfce_or_dde_or_gnome; then
APP_TARGET_DIR="$TARGET_BASE/applications" APP_TARGET_DIR="$TARGET_BASE/applications"
echo "检测到 XFCE/DDE 桌面环境,使用目标目录: $APP_TARGET_DIR" echo "检测到 XFCE/DDE/GNOME 桌面环境,使用目标目录: $APP_TARGET_DIR"
else else
APP_TARGET_DIR="$TARGET_BASE/applications/apm" APP_TARGET_DIR="$TARGET_BASE/applications/apm"
echo "使用目标目录: $APP_TARGET_DIR" echo "使用目标目录: $APP_TARGET_DIR"