我正在通过 Wine/PoL 使用 MS Office 2007,并且为它们制作了如下桌面文件:
首先:
[Desktop Entry]
Encoding=UTF-8
Name=Word 2007
GenericName=Game
Comment=PlayOnLinux
Type=Application
Exec=/usr/share/playonlinux/playonlinux --run "Microsoft Word 2007"
Icon=/home/sebastian/.PlayOnLinux//icones/full_size/Word 2007
Categories=Office;
用于打开文件:(z:
是葡萄酒链接至/
)
[Desktop Entry]
Encoding=UTF-8
Name=Mit Word 2007 öffnen
GenericName=Game
Comment=PlayOnLinux
Type=Application
Exec=/usr/share/playonlinux/playonlinux --run "Microsoft Word 2007" z:%f
Icon=/home/sebastian/.PlayOnLinux//icones/full_size/Word 2007
Categories=Office;
但是,文件打开快捷方式不接受带有空格的文件(它们会被替换%20
)。
现在我想将这两个文件合并为一个,它应该启动 Word,并且如果提供的话,打开一个可能包含空格的文档。
我怎样才能做到这一点?
答案1
我自己找到了一个解决方案。我创建了以下脚本:
#!/bin/bash
if [ "$2" != "" ]
then
mode="open"
DATA="file:///Z:$2"
DATA=${DATA// /%20}
else
mode="noopen"
fi
case $1 in
winword)
if [ $mode == "open" ]
then
/usr/share/playonlinux/playonlinux --run "Microsoft Word 2007" "$DATA"
else
/usr/share/playonlinux/playonlinux --run "Microsoft Word 2007"
fi
;;
excel)
if [ $mode == "open" ]
then
/usr/share/playonlinux/playonlinux --run "Microsoft Excel 2007" "$DATA"
else
/usr/share/playonlinux/playonlinux --run "Microsoft Excel 2007"
fi
;;
pwrpoint)
if [ $mode == "open" ]
then
/usr/share/playonlinux/playonlinux --run "Microsoft Powerpoint 2007" "$DATA"
else
/usr/share/playonlinux/playonlinux --run "Microsoft Powerpoint 2007"
fi
;;
*)
exit
;;
esac
它将文件名转换为 URL ( file:///Z:/home/sebastian/Documents/test.docx
)。它还确定是否提供第二个参数,因此 Office 不会说File "Z:" not found
。
发射器现在看起来像这样:(这个用于单词)
[Desktop Entry]
Encoding=UTF-8
Name=Word 2007
GenericName=Word Processor
Comment=PlayOnLinux
Type=Application
Exec=/home/sebastian/.PlayOnLinux//wineprefix/Office2007/MSOfficeExecutor.sh winword %f
Icon=/home/sebastian/.PlayOnLinux//icones/full_size/Word 2007
Categories=Office;