一个小程序:用系统托盘图标控制需要后台运行的程序
Tofloor
poster avatar
梦幻大陆
deepin
2018-06-18 22:18
Author
本帖最后由 rocket 于 2018-6-19 22:58 编辑

本程序用于在系统托盘位置显示一个图标,用于控制你需要后台运行的程序。


(2018-6-19修改)用 `HOME/config/trayctl/app.json` 指定程序`exec`和参数`args`,环境变量`envs`、工作目录`wd`。
其中`args`中如果需要多个参数,应当用空格隔开(例如:`"args":"-a xx -b xx -c xx xxxxx"`)。
环境变量`envs`格式为:"NAME1=VALUE1;NAME2=VALUE2",将会附加到当前环境变量之中。
配置文件示例:
{
        "exec":"/path/to/exec",
        "args":"-a xx -b xx -c xx xxxxx",
        "envs":"NAME1=VALUE1;NAME2=VALUE2",
        "wd":"/path/to/work"
}


作为示例,把 `config` 目录复制到 `HOME` 中,可以在任意位置运行 `trayctl`,用于控制一个`gedit`。


##如何控制多个程序
只需要把程序改名,例如改成: `ctl01`,那么这个程序就会读取配置程序(2018-6-19修改)`HOME/config/ctl01/app.json`。


更改图标:只需要`HOME/config/你的名字/`目录中的`run.png`、`stop.png`。


##源代码
源代码在[https://gitee.com/rocket049/golang_test](https://gitee.com/rocket049/golang_test)
下面的`dev/trayctl`、`dev/mapjson`中。


点击打开:[https://gitee.com/rocket049/golang_test](https://gitee.com/rocket049/golang_test)


**注:使用 Interrupt 信号关闭程序,被控制的程序应当正确处理该信号。**
依赖关系:
GTK3
Reply Favorite View the author
All Replies
avatar
许自强
deepin
2018-06-19 23:25
#1
诶,这个是干嘛用的啊?
Reply View the author
avatar
wtz
deepin
2018-06-19 23:47
#2
感觉Interrupt似乎不是很通用?建议改用Terminate。
Reply View the author
avatar
梦幻大陆
deepin
2018-06-20 05:47
#3
CTRL-C 就是 Interrupt 信号,应该是最常用的。
改了不少BUG,现在已经基本完善了。
Reply View the author
avatar
梦幻大陆
deepin
2018-06-20 05:51
#4
https://bbs.deepin.org/post/158446
诶,这个是干嘛用的啊?

控制一个后台运行的程序,并实时显示它的状态,显示在托盘上。
Reply View the author
avatar
风吹过的绿洲
deepin
2018-06-20 06:04
#5
没有效果图,差评
Reply View the author
avatar
许自强
deepin
2018-06-20 06:35
#6
https://bbs.deepin.org/post/158446
没有效果图,差评

是一个监控程序咯?做得更加易用一点嘛
Reply View the author
avatar
梦幻大陆
deepin
2018-06-20 06:42
#7
https://bbs.deepin.org/post/158446
是一个监控程序咯?做得更加易用一点嘛

不是监控,是帮助控制命令行程序的,例如你编写了一个fcgi程序,每次修改后要到终端关掉重启,用这个配置好之后,就只要鼠标点,点一点启动、点一点关闭。
Reply View the author
avatar
ih******op@vip.qq.com
deepin
2018-06-20 06:51
#8
为什么不放到~/.config 现在在home目录下各种软件生成各种文件 好乱啊
Reply View the author
avatar
梦幻大陆
deepin
2018-06-20 06:57
#9
https://bbs.deepin.org/post/158446
为什么不放到~/.config 现在在home目录下各种软件生成各种文件 好乱啊

用起来方便,文件管理器默认不显示 “.config”
Reply View the author
avatar
ih******op@vip.qq.com
deepin
2018-06-20 18:20
#10
https://bbs.deepin.org/post/158446
用起来方便,文件管理器默认不显示 “.config”

就是因为不想显示 现在很多软件都往home里面随意生成文件。所以才有.config,就是预留给软件保存配置文件的,你可以进去看看,这是一个行业规范
Reply View the author
avatar
梦幻大陆
deepin
2018-06-21 23:16
#11
升级到 1.3,现在子进程输入、输出信息不会出错,支持 pydoc3
Reply View the author