diff --git a/README.md b/README.md index a94ed9d..fc65a21 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ - 🔧 **硬件加速**:可选的 GPU 硬件加速支持 - 🪟 **窗口切换器**:左上角增加切换悬浮窗,方便切换到后台窗口,为后续添加其它功能做基础 - 🤖 **自动启动**:可配置自动启动微信和QQ客户端(可选) +- 📋 **桌面快捷方式集成**:自动扫描 `~/Desktop/` 下的 `.desktop` 文件并添加到右键菜单,方便启动第三方应用(如通过 proot-apps 安装的应用) ## 截图展示 ![微信截图](./docs/images/wechat-selkies-1.jpg) diff --git a/README_en.md b/README_en.md index 039e6f4..889a8d0 100644 --- a/README_en.md +++ b/README_en.md @@ -33,6 +33,8 @@ This project packages the official WeChat/QQ Linux client in a Docker container, - 🖥️ **AMD64 and ARM64 Architecture Support**: Compatible with mainstream CPU architectures - 🔧 **Hardware Acceleration**: Optional GPU hardware acceleration support - 🪟 **Window Switcher**: Added a floating window switcher in the top left corner for easy switching to background windows, laying the foundation for adding other features in the future +- 🤖 **Auto Start**: Configurable auto-start for WeChat and QQ clients (optional) +- 📋 **Desktop Shortcut Integration**: Automatically scans `.desktop` files in `~/Desktop/` and adds them to the right-click menu, making it easy to launch third-party applications (e.g., apps installed via proot-apps) ## Screenshots ![WeChat Screenshot](./docs/images/wechat-selkies-1.jpg) diff --git a/root/scripts/start.sh b/root/scripts/start.sh index a6f914a..d253be7 100755 --- a/root/scripts/start.sh +++ b/root/scripts/start.sh @@ -8,10 +8,52 @@ if [ ! -f /config/.config/openbox/rc.xml ] || grep -A20 "" /config/.config openbox --reconfigure fi -# update openbox menu if differs from default -if [ ! -f /config/.config/openbox/menu.xml ] || ! cmp /defaults/menu.xml /config/.config/openbox/menu.xml; then - mkdir -p /config/.config/openbox - cp /defaults/menu.xml /config/.config/openbox/menu.xml +# generate openbox menu +mkdir -p /config/.config/openbox +cp /defaults/menu.xml /tmp/menu.xml + +if ls "$HOME/Desktop/"*.desktop >/dev/null 2>&1; then + for desktop_file in "$HOME/Desktop/"*.desktop; do + name=$(grep -E "^Name=" "$desktop_file" | head -n 1 | cut -d "=" -f 2-) + exec_cmd=$(grep -E "^Exec=" "$desktop_file" | head -n 1 | cut -d "=" -f 2-) + icon=$(grep -E "^Icon=" "$desktop_file" | head -n 1 | cut -d "=" -f 2-) + + # strip %U, %u, %F, %f + exec_cmd=$(echo "$exec_cmd" | sed 's/ %[fFuU]//g') + + # resolve icon path if it's just a name (not an absolute path) + if [ -n "$icon" ] && [ "${icon#/}" = "$icon" ]; then + icon_resolved="" + # search in proot-apps icons (prefer 256x256) + for size in 256x256 512x512 128x128 64x64 48x48 scalable; do + found=$(find /config/proot-apps/*/usr/share/icons/hicolor/"$size"/apps/"$icon".* 2>/dev/null | head -n 1) + if [ -n "$found" ]; then + icon_resolved="$found" + break + fi + done + # fallback: search system icons + if [ -z "$icon_resolved" ]; then + found=$(find /usr/share/icons/hicolor/*/apps/"$icon".* 2>/dev/null | head -n 1) + [ -n "$found" ] && icon_resolved="$found" + fi + [ -n "$icon_resolved" ] && icon="$icon_resolved" + fi + + # handle missing icon + [ -z "$icon" ] && icon="/usr/share/pixmaps/xterm-color_48x48.xpm" + + # escape XML entities + exec_cmd=$(echo "$exec_cmd" | sed 's/&/\&/g; s//\>/g') + name=$(echo "$name" | sed 's/&/\&/g; s//\>/g; s/"/\"/g') + icon=$(echo "$icon" | sed 's/&/\&/g; s//\>/g; s/"/\"/g') + + sed -i "//a \\${exec_cmd}" /tmp/menu.xml + done +fi + +if [ ! -f /config/.config/openbox/menu.xml ] || ! cmp /tmp/menu.xml /config/.config/openbox/menu.xml; then + cp /tmp/menu.xml /config/.config/openbox/menu.xml openbox --reconfigure fi