mirror of
https://gitee.com/spark-store-project/spark-wine
synced 2025-12-18 21:11:39 +08:00
finished wrapper
This commit is contained in:
@@ -0,0 +1,40 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# 定义日志函数
|
||||||
|
log.warn() { echo -e "[\e[33mWARN\e[0m]: \e[1m$*\e[0m"; }
|
||||||
|
log.error() { echo -e "[\e[31mERROR\e[0m]: \e[1m$*\e[0m"; }
|
||||||
|
log.info() { echo -e "[\e[96mINFO\e[0m]: \e[1m$*\e[0m"; }
|
||||||
|
log.debug() { echo -e "[\e[32mDEBUG\e[0m]: \e[1m$*\e[0m"; }
|
||||||
|
|
||||||
|
desktop_dir="${HOME}/.local/share/applications/wine/Programs"
|
||||||
|
|
||||||
|
find "$desktop_dir" -type f -name "*.desktop" | while read -r desktop_file; do
|
||||||
|
log.debug "处理文件: $desktop_file"
|
||||||
|
|
||||||
|
exec_line=$(grep -i '^Exec=' "$desktop_file" | cut -d'=' -f2- | xargs)
|
||||||
|
wineprefix=$(echo "$exec_line" | grep -o 'WINEPREFIX=[^ ]*' | cut -d'=' -f2)
|
||||||
|
|
||||||
|
# 核心修复:使用正则表达式提取完整Windows路径
|
||||||
|
exe_win_path=$(echo "$exec_line" | grep -o 'C:\\\\.*\.lnk' | head -1)
|
||||||
|
|
||||||
|
log.debug "WINEPREFIX: '$wineprefix'"
|
||||||
|
log.debug "原始 Windows 路径: '$exe_win_path'"
|
||||||
|
|
||||||
|
if [[ -z "$wineprefix" || -z "$exe_win_path" ]]; then
|
||||||
|
log.warn "参数不完整,跳过"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 路径转换:处理转义字符和路径分隔符
|
||||||
|
exe_win_path_unix=$(printf "%b" "$exe_win_path" | sed -e 's/\\/\//g' -e 's/^[cC]://')
|
||||||
|
exe_path_unix="${wineprefix}/dosdevices/c:/${exe_win_path_unix}"
|
||||||
|
|
||||||
|
log.debug "转换后的 UNIX 路径: $exe_path_unix"
|
||||||
|
|
||||||
|
if [[ ! -f "$exe_path_unix" ]]; then
|
||||||
|
log.info "文件不存在: $exe_path_unix, 删除 $desktop_file"
|
||||||
|
rm "$desktop_file"
|
||||||
|
else
|
||||||
|
log.debug "文件存在: $exe_path_unix"
|
||||||
|
fi
|
||||||
|
done
|
||||||
@@ -17,13 +17,13 @@ gui_dialog() {
|
|||||||
|
|
||||||
# Check if no arguments were passed
|
# Check if no arguments were passed
|
||||||
if [[ $# -eq 0 ]]; then
|
if [[ $# -eq 0 ]]; then
|
||||||
gui_dialog --info --text="使用方法:\nUsage:\n\nspark-wine <application.exe>\n\n请提供要运行的 Windows 应用程序。\nPlease provide the Windows application to run."
|
gui_dialog --info --text="使用方法:\nUsage:\n\nspark-wine9 <application.exe>\n\n请提供要运行的 Windows 应用程序。\nPlease provide the Windows application to run."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if spark-wine is installed
|
# Check if spark-wine is installed
|
||||||
if ! command -v spark-wine &>/dev/null; then
|
if ! command -v spark-wine &>/dev/null; then
|
||||||
gui_dialog --question --text="您尚未安装 spark-wine ,是否安装以运行 Windows 应用?\nYou haven't installed spark-wine yet. Would you like to install it to run Windows applications?"
|
gui_dialog --question --text="您尚未安装 spark-wine9 ,是否安装以运行 Windows 应用?\nYou haven't installed spark-wine yet. Would you like to install it to run Windows applications?"
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
log.error "User refused to install. Exiting."
|
log.error "User refused to install. Exiting."
|
||||||
exit 1
|
exit 1
|
||||||
@@ -31,12 +31,12 @@ if ! command -v spark-wine &>/dev/null; then
|
|||||||
|
|
||||||
|
|
||||||
# Install spark-wine with progress indicator
|
# Install spark-wine with progress indicator
|
||||||
pkexec bash -c "aptss update && aptss install spark-wine spark-wine-mono -y" | gui_dialog --progress --pulsate --auto-close --no-cancel --text="正在安装,请保持网络畅通,耐心等待\nInstalling, please keep network connection and wait patiently"
|
pkexec bash -c "aptss update && aptss install spark-wine9 spark-wine9-mono -y" | gui_dialog --progress --pulsate --auto-close --no-cancel --text="正在安装,请保持网络畅通,耐心等待\nInstalling, please keep network connection and wait patiently"
|
||||||
INSTALL_STATUS=${PIPESTATUS[0]}
|
INSTALL_STATUS=${PIPESTATUS[0]}
|
||||||
|
|
||||||
# Check the installation status correctly
|
# Check the installation status correctly
|
||||||
if [[ $INSTALL_STATUS -ne 0 ]]; then
|
if [[ $INSTALL_STATUS -ne 0 ]]; then
|
||||||
gui_dialog --error --text="安装出错,请手动执行以下指令查看错误并反馈:\nError occurred during installation. Please execute the command below to view the error log:\n\nsudo aptss install spark-wine spark-wine-mono -y"
|
gui_dialog --error --text="安装出错,请手动执行以下指令查看错误并反馈:\nError occurred during installation. Please execute the command below to view the error log:\n\nsudo aptss install spark-wine9 spark-wine9-mono -y"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -44,15 +44,23 @@ fi
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Run spark-wine with WINEPREFIX
|
# Run spark-wine with WINEPREFIX
|
||||||
export WINEPREFIX="$HOME/.wine"
|
export WINEPREFIX="${WINEPREFIX:=$HOME/.deepinwine/spark-wine9-custom}"
|
||||||
export APPRUN_CMD="spark-wine"
|
export APPRUN_CMD="/usr/bin/spark-wine9"
|
||||||
export SHELL_DIR="/opt/spark-dwine-helper"
|
export SHELL_DIR="/opt/spark-dwine-helper"
|
||||||
|
|
||||||
|
if [[ "$WINEPREFIX" != $HOME/.deepinwine/spark-wine9-custom ]];then
|
||||||
|
${APPRUN_CMD} "$@"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(
|
(
|
||||||
|
mkdir -p ${WINEPREFIX}
|
||||||
${SHELL_DIR}/spark-dwine-helper/scale-set-helper/set-wine-scale.sh ${WINEPREFIX} &
|
${SHELL_DIR}/spark-dwine-helper/scale-set-helper/set-wine-scale.sh ${WINEPREFIX} &
|
||||||
# ${APPRUN_CMD} reg add 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v winemenubuilder.exe /f &
|
# ${APPRUN_CMD} reg add 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v winemenubuilder.exe /f &
|
||||||
wait
|
wait
|
||||||
) | gui_dialog --progress --pulsate --auto-close --no-cancel --text="正在准备应用...\nPreparing Windows APP..."
|
) | gui_dialog --progress --pulsate --auto-close --no-cancel --text="正在准备应用...\nPreparing Windows APP..."
|
||||||
|
|
||||||
${APPRUN_CMD} "$@"
|
${APPRUN_CMD} "$@"
|
||||||
|
/opt/spark-dwine-helper/spark-dwine-helper/spark-wine-desktop-auto-cleanner
|
||||||
1
spark-dwine-helper/s-wine-helper/usr/local/bin/spark-wine9
Symbolic link
1
spark-dwine-helper/s-wine-helper/usr/local/bin/spark-wine9
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../bin/spark-wine-launcher
|
||||||
@@ -6,7 +6,8 @@ Icon=spark-dwine-helper
|
|||||||
MimeType=
|
MimeType=
|
||||||
Name=Spark Wine App Settings
|
Name=Spark Wine App Settings
|
||||||
Name[zh_CN]=星火Wine应用设置
|
Name[zh_CN]=星火Wine应用设置
|
||||||
|
NoDisplay=false
|
||||||
StartupWMClass=spark-dwine-helper
|
StartupWMClass=spark-dwine-helper
|
||||||
Terminal=False
|
Terminal=False
|
||||||
Type=Application
|
Type=Application
|
||||||
NoDisplay=false
|
X-Deepin-Vendor=user-custom
|
||||||
|
|||||||
Reference in New Issue
Block a user