重金悬赏bash脚本
Tofloor
poster avatar
Hello
deepin
2020-07-31 18:35
Author
本帖最后由 cht 于 2020-7-31 10:54 编辑

我这有个想打开的东西,它的后缀是svpk
我的目标是让这个后缀文件用我的软件打开
我这个软件安装后,文件会自动解压缩到主目录Synthv2文件夹下面
想实现方式是$HOME/Synthv2/synthv-studio xxx.svpk的效果
  1. #!/bin/sh

  2. if [ ! -d $HOME/Synthv2 ]; then
  3.     cp -r /opt/apps/com.synthesizerv/files/files.7z $HOME
  4.     cd $HOME
  5.     7z x files.7z
  6.     rm files.7z
  7. fi
  8. $HOME/Synthv2/synthv-studio
Copy the Code

这是我的bash脚本
  1. [Desktop Entry]
  2. Categories=Graphics;VectorGraphics;GTK;
  3. Comment=详情
  4. Exec=/opt/apps/com.synthesizerv/files/synthv.sh
  5. Icon=synthv
  6. Name=SV
  7. Terminal=false
  8. Type=Application
  9. X-Deepin-Vendor=user-custom
Copy the Code

这是我的desktop写法

https://www.jianguoyun.com/p/DdB3cpwQ4-GFCBiDlLED
要安装包在这里
预测实现效果:

Reply Favorite View the author
All Replies
1 / 2
To page
avatar
Hello
deepin
2020-07-31 18:38
#1
看一看累,不要钱!!
Reply View the author
avatar
Hello
deepin
2020-07-31 18:39
#2
悬赏了!!!!!!
Reply View the author
avatar
Hello
deepin
2020-07-31 18:41
#3
我是不是招你们恨啊,怎么连悬赏都没人
Reply View the author
avatar
Hello
deepin
2020-07-31 18:44
#4
我再顶顶顶顶
Reply View the author
avatar
梁山伯住阳台
deepin
2020-07-31 18:54
#5
吃瓜群众路过
Reply View the author
avatar
蔡EEPIN
deepin
2020-07-31 18:54
#6
路过帮顶
Reply View the author
avatar
Hello
deepin
2020-07-31 18:54
#7
求搞搜,搞搜来一个,以后我若成功,你就是坐上斌
Reply View the author
avatar
Cris.Q
deepin
2020-07-31 19:09
#8
脚本什么的不太清楚,但是有一点就是dektop下面这个exec是可以带参数的:
其中 Exec 常用的参数有:%f %F %u %U
%f:单个文件名,即使选择了多个文件。如果已选择的文件不在本地文件系统中(比如说在HTTP或者FTP上),这个文件将被作为一个临时文件复制到本地,%f将指向本地临时文件;
%F:文件列表。用于程序可以同时打开多个本地文件。每个文件以分割段的方式传递给执行程序。
%u:单个URL。本地文件以文件URL或文件路径的方式传递。
%U:URL列表。每个URL以分割段的方式传递给执行程序。本地文件以文件URL或文件路径的方式传递。

这四个参数可以让exec后面的程序打开对应文件(例如vim a.txt中这个a.txt就是对应文件)
Reply View the author
avatar
Hello
deepin
2020-07-31 19:22
#9
https://bbs.deepin.org/post/198087
脚本什么的不太清楚,但是有一点就是dektop下面这个exec是可以带参数的:
其中 Exec 常用的参数有:%f %F % ...

实测不行,是bash的缘故,我bash最后一行写的是直接打开,不能够让它打开目标文件
Reply View the author
avatar
Feng Yu
deepin
2020-07-31 19:26
#10
Linux下是通过MIME Type关联文件类型的,所以你需要在desktop添加一个MIME type注册就行了
Reply View the author
avatar
走钢丝
deepin
2020-07-31 19:26
#11
https://bbs.deepin.org/post/198087
实测不行,是bash的缘故,我bash最后一行写的是直接打开,不能够让它打开目标文件 ...

脚本也可以传命令行参数啊,应该保存在变量 $1、$2、$n 中吧。具体可参考 /usr/share/applications 中的 deepin-wine 相关应用(QQ、微信什么的)对应的 desktop 中的脚本文件。
Reply View the author
avatar
Hello
deepin
2020-07-31 19:30
#12
https://bbs.deepin.org/post/198087
脚本也可以传命令行参数啊,应该保存在变量 $1、$2、$n 中吧。具体可参考 /usr/share/applications 中的  ...

怎么玩?
Reply View the author
avatar
Hello
deepin
2020-07-31 19:33
#13
https://bbs.deepin.org/post/198087
Linux下是通过MIME Type关联文件类型的,所以你需要在desktop添加一个MIME type注册就行了 ...

这不是注册的问题,我的脚本目前不支持传递命令行参数
Reply View the author
avatar
Feng Yu
deepin
2020-07-31 19:36
#14
https://bbs.deepin.org/post/198087
这不是注册的问题,我的脚本目前不支持传递命令行参数

有svpk样本没?发上来,分分钟解决。等我手头的事忙完就可以搞定,so easy
Reply View the author
avatar
走钢丝
deepin
2020-07-31 19:36
#15

在脚本中引用变量 $1 就行了啊。。可以参观 /opt/deepinwine/tools 中的脚本,看看它们的写法。

另外,自定义 mimetype 不注册的话,还是需要手工指定文件类型打开方式的。具体参考:https://www.jianshu.com/p/4617e8e600ad
Reply View the author
avatar
gangbanbro
deepin
2020-07-31 19:36
#16
执行脚本的时候  加空格 [参数1] 空格 [参数2]...可以一直传

就比如
./start.sh   filename
你在start.sh中可以直接用$1来代表后面跟的参数filename
就是你脚本运行命令后跟的东西,就是默认传参给 $1、$2、$n 中了。
比较类似于java main方法的String[] args
不知道我这样说你理解不
Reply View the author
avatar
gangbanbro
deepin
2020-07-31 18:35
#17
https://bbs.deepin.org/post/198087
执行脚本的时候  加空格 [参数1] 空格 [参数2]...可以一直传

就比如

你这里你看看是不是吧shell脚本改为
$HOME/Synthv2/synthv-studio  $1

然后图标里面的exec上加上%f
你在启动就可以了?

试试,我也 不知道你是不是这个意思
Reply View the author
avatar
Hello
deepin
2020-07-31 19:46
#18
https://bbs.deepin.org/post/198087
有svpk样本没?发上来,分分钟解决。等我手头的事忙完就可以搞定,so easy

https://dreamtonics.com/synthv/download/
你随便下一个吧
Reply View the author
avatar
Hello
deepin
2020-07-31 19:52
#19
https://bbs.deepin.org/post/198087
你这里你看看是不是吧shell脚本改为
$HOME/Synthv2/synthv-studio  $1

搞定了大佬!!!!!
Reply View the author
avatar
Hello
deepin
2020-07-31 21:17
#20
搞定了,这个帖子留给新人下载软件吧
Reply View the author
1 / 2
To page