Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Open
lvbuwei opened this issue Nov 28, 2019 · 2 comments
Open

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

lvbuwei opened this issue Nov 28, 2019 · 2 comments

Comments

@lvbuwei
Copy link

lvbuwei commented Nov 28, 2019

比如,我用的是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()
}
@bitepeng
Copy link
Owner

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

@lvbuwei
Copy link
Author

lvbuwei commented Nov 30, 2019

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants