双击desktop文件执行结果与命令行执行不符
Tofloor
poster avatar
安洛
deepin
2020-05-25 01:28
Author
用wine安装了微信,想配合stalonetray使用,写了这个desktop文件:
  1. [Desktop Entry]
  2. Name=微信
  3. Exec= stalonetray & env WINEPREFIX=~/.wechat WINEARCH=win32 wine /home/chenxiex/.wechat/drive_c/Program\ Files/Tencent/WeChat/WeChat.exe
  4. Icon=/home/chenxiex/Pictures/Icons/wechat.jpeg
  5. Type=Application
  6. Categories=Chat
Copy the Code

当我使用./微信.desktop时,是可以正常执行的;但是当我双击这个文件时,却没有反应。
请问原因是什么呢?

Reply Favorite View the author
All Replies
avatar
安洛
deepin
2020-05-25 01:30
#1
在命令行执行时有这样的错误:
  1. ./微信.desktop:行1: [Desktop:未找到命令
Copy the Code
Reply View the author
avatar
RedPanda
deepin
2020-05-25 01:42
#2
因为他就不是个可执行文件?
chmod +x了没?
Reply View the author
avatar
luming
deepin
2020-05-25 01:43
#3
deepin是这样写的:
#!/usr/bin/env xdg-open

[Desktop Entry]
Encoding=UTF-8
Type=Application
X-Created-By=Deepin WINE Team
Categories=chat;
Icon=com.qq.weixin.deepin
Exec="/opt/apps/com.qq.weixin.deepin/files/run.sh" -u %u
Name=WeChat
Name[zh_CN]=微信
Comment=Tencent WeChat Client on Deepin Wine
StartupWMClass=WeChat.exe
MimeType=
X-Deepin-CreatedBy=com.deepin.dde.daemon.Launcher
X-Deepin-AppID=com.qq.weixin.deepin
Reply View the author
avatar
安洛
deepin
2020-05-25 01:44
#4
https://bbs.deepin.org/post/194998
因为他就不是个可执行文件?
chmod +x了没?

已经确认是可执行了。
如果没有权限的话命令也不能执行才对。
Reply View the author
avatar
安洛
deepin
2020-05-25 01:45
#5
https://bbs.deepin.org/post/194998
deepin是这样写的:
#!/usr/bin/env xdg-open

这是deepin-wine的微信。我用了wine5.0安装了最新版的微信。
Reply View the author
avatar
安洛
deepin
2020-05-25 01:45
#6
https://bbs.deepin.org/post/194998
因为他就不是个可执行文件?
chmod +x了没?

另外我看了别的.desktop文件,都是不需要可执行权限的。
Reply View the author
avatar
走钢丝
deepin
2020-05-25 01:46
#7
那行内容写脚本中,然后在那行写入脚本路径。
Reply View the author
avatar
安洛
deepin
2020-05-25 01:52
#8
本帖最后由 chenxiex 于 2020-5-24 18:10 编辑
https://bbs.deepin.org/post/194998
那行内容写脚本中,然后在那行写入脚本路径。

可以是可以了。
Reply View the author
avatar
deepin
2020-05-25 02:48
#9
我前面发有帖子,里面有精简过的模板,有注释,楼主可以看下
Reply View the author
Comments
chenxiex
2020-05-25 02:59
好的谢谢。
avatar
Maicss
deepin
2020-05-25 03:14
#10
desktop不需要可执行权限
将&更改为&&看看是否有问题
测试时直接运行exec一项
直接加可执行权限相当于运行脚本,第一行下边的内容会被认为是 变量名=表达式,而第一行本身是语法错误.
修改后尝试一下看有没有问题



Reply View the author
avatar
安洛
deepin
2020-05-25 03:46
#11
https://bbs.deepin.org/post/194998
desktop不需要可执行权限
将&更改为&&看看是否有问题
测试时直接运行exec一项

&&不是前一个命令执行完之后才会运行下一个吗?但stalonetray是需要常驻后台的,这个命令不会主动停止。
测试的时候直接运行exec一项是没有问题的。
我这个文件打开错误的原因已经找到了,是主目录不能写成~/
Reply View the author
avatar
安洛
deepin
2020-05-25 03:56
#12
https://bbs.deepin.org/post/194998
desktop不需要可执行权限
将&更改为&&看看是否有问题
测试时直接运行exec一项

&&不是前一个命令执行完之后才会运行下一个吗?但stalonetray是需要常驻后台的,这个命令不会主动停止。
测试的时候直接运行exec一项是没有问题的。
我这个文件打开错误的原因已经找到了,是主目录不能写成~/。
Reply View the author
avatar
Feng Yu
deepin
2020-05-25 04:53
#13
desktop文件不是你这么用的,exec也不是你这么写的,那玩意根本不是你理解的开个shell解释命令,它根本不是启动shell运行的。

建议去看看freedesktop官方文但是怎么描述desktop file的
Reply View the author
Comments
chenxiex
2020-05-25 04:59
看来是我学习不足,我去看看文档吧