b0pass icon indicating copy to clipboard operation
b0pass copied to clipboard

希望有自定义执行命令的功能

Open lvbuwei opened this issue 6 years ago • 2 comments

比如,我用的是linux,默认调用的是xdg-open,但是问题是这个命令只要调一次,就会生成一个新的图片进程实例,我在手机上点了10次,电脑上会出现10个运行的图片,最后我得一个一个关了才行,如果能在配置文件中进行自己配置命令就好了,比如,我改了一下代码,让他运行 eog -w,这样,就只会运行一个界面实例了,如果能支持就方便了。

# 应用系统设置
[setting]
    logpath = "tmp/log"
    port    = 8899
    uri     = "eog -w"

下面代码就可以支持

func Open(uri string) error {
	//runtime.GOOS
	run, ok := commands[runtime.GOOS]
	if !ok {
		return fmt.Errorf("don't know how to open things on %s platform", runtime.GOOS)
	}
  _uri := g.Config().GetString("setting.uri")
  if len(_uri) >0 {
    run = _uri
  }
	//exec.Command
	run = run + " " + uri
  fmt.Println(run)
	cmds := strings.Split(run, " ")
	cmd := exec.Command(cmds[0], cmds[1:]...)
	//cmd.Start
	fmt.Println("[CommandAs]", cmds)
	return cmd.Start()
}

lvbuwei avatar Nov 28 '19 04:11 lvbuwei

经测试 eog -w 在centos上面也是点击多张图片,也不会达到“只会运行一个界面实例”的效果。你那边测试是可以的吗?

bitepeng avatar Nov 29 '19 08:11 bitepeng

对,我的ubuntu18.04是没有问题的, 其实,就算eog这个不支持,也回有别的支持,如果能扩展到支持配置,就大大的扩展的功能的自由度。

lvbuwei avatar Nov 30 '19 01:11 lvbuwei