此链接:https://unix.stackexchange.com/questions/509360
它解释了如何将程序添加到 Wine 菜单:
wine winemenubuilder /path/to/link.lnk
但我没有特定程序的 .lnk 文件。
如何创建 .lnk 文件?
答案1
我发明了正确的解决方案,可以保证与葡萄酒完美兼容:
lnk () {
cat <<EOF > /tmp/shortcut.vbs
Set FSO = CreateObject("Scripting.FileSystemObject")
TargetPath = FSO.GetAbsolutePathName(WScript.Arguments(0))
WorkingDirectory = FSO.GetParentFolderName(TargetPath)
Set lnk = CreateObject("WScript.Shell").CreateShortcut(WScript.Arguments(1))
lnk.TargetPath = TargetPath
lnk.WorkingDirectory = WorkingDirectory
lnk.Save
EOF
wine wscript '//B' 'Z:\tmp\shortcut.vbs' "$@" 2> /dev/null
local exit_code=$?
sync; rm -f /tmp/shortcut.vbs; sync
return $exit_code
}
我能够干净地调用该函数:
lnk 'C:\Program Files (x86)\Rufus\rufus.exe' 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Rufus.lnk'
在我的情况下,这是一个程序的安装功能:
update_rufus () {
local old_version="$(cat ~/'.wine/dosdevices/c:/Program Files (x86)/Rufus/version.txt' 2> /dev/null)"
local link="$(wget -q 'https://api.github.com/repos/pbatard/rufus/releases/latest' -O - | grep '"browser_download_url":' | grep -o -m 1 -E '[^"]+/rufus-[0-9.]+\.exe')"
wget -q "$link" -O rufus.exe
local exit_code=$?
if [[ $exit_code -eq 0 ]]; then
mkdir -p ~/'.wine/drive_c/Program Files (x86)/Rufus'
echo "$link" | perl -lpe 's|^.*/rufus-([0-9.]+)\.exe$|\1|' > ~/'.wine/drive_c/Program Files (x86)/Rufus/version.txt'
mv rufus.exe ~/'.wine/drive_c/Program Files (x86)/Rufus'
lnk 'C:\Program Files (x86)\Rufus\rufus.exe' 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Rufus.lnk'
local new_version="$(cat ~/'.wine/dosdevices/c:/Program Files (x86)/Rufus/version.txt')"
if [[ "$new_version" == "$old_version" ]]; then
echo "Rufus is already the newest version ($new_version)."
else
echo "Rufus has been successfully updated ($new_version)."
fi
else
echo 'An error has occurred.'
fi
return $exit_code
}