[Share Experiences] 用python写了个托盘小工具
Tofloor
poster avatar
ludongping
deepin
2022-05-03 19:34
Author

可以方便的在托盘区加上自己常用的功能,也可以监控某个脚本的执行结果并相应的改变图标,比如我需要启动Proxy去跳到公司内网的

image.png

大家有啥建议?我优化好了再发出来

配置文件是这样的:

{
  "style": { "fontName":"MiSans Normal", "fontStyle":0, "fontSize":24},
  "trays": [
    {
      "image": "red.svg",
      "menus": [
        {"label": "启动Proxy","cmd": ["/data/soft/bin/proxy_inner"],
  		"style": { "fontName":"MiSans Normal", "fontStyle":0, "fontSize":32}
	},
        {"label": "-"},
        {"label": "Gvim","cmd": ["gvim"]},
        {"label": "IDEA Toolbox","cmd": ["/home/tony/.local/share/JetBrains/Toolbox/bin/jetbrains-toolbox"]},
        {"label": "IDEA","cmd": ["/home/tony/.local/share/JetBrains/Toolbox/apps/IDEA-C/ch-0/latest/bin/idea.sh"]},
        {"label": "VS Code","cmd": ["/opt/apps/com.visualstudio.code/files/code/code", "--no-sandbox", "--unity-launch"]},
        {"label": "DBeaver","cmd": ["/opt/apps/io.dbeaver.community/files/dbeaver"]},
        {"label": "Drawio","cmd": ["/opt/apps/net.diagrams.drawio/files/drawio","--enable-crashpad"]},
        {"label": "WPS","cmd": ["wps"]},
        {"label": "-"},
        {"label":"Deepin","children": [
          {"label": "Deepin Editor","cmd": ["deepin-editor"]},
          {"label": "Deepin Store","cmd": ["deepin-home-appstore-client"]},
          {"label": "Deepin Control Center","cmd": ["dde-control-center", "--show"]},
          {"label": "Deepin System Monitor","cmd": ["deepin-system-monitor"]}
        ]},
        {"label": "-"},
        {"label": "Exit", "type": "EXIT"}
      ],
      "monitor": {
        "script": "netstat -nltp 2>/dev/null | grep :3128 | wc -l",
        "interval": 5,
        "images": ["./gray.svg","./green.svg"]
      }
    }
  ]
}

Reply Favorite View the author
All Replies
liwl
deepin
2022-05-03 19:59
#1

加个icon

Reply View the author
black_white_bear
deepin
2022-05-03 22:21
#2

这是用python直接实现了dtk的效果和插件吗?

Reply View the author
ljq790615
deepin
2022-05-03 23:21
#3

牛人,先支持!

Reply View the author
andktan
deepin
2022-05-04 00:34
#4

kissing_heart

Reply View the author
ludongping
deepin
2022-05-04 00:36
#5
black_white_bear

这是用python直接实现了dtk的效果和插件吗?

很简单的,网上搜一下 python + 系统托盘

Reply View the author
ludongping
deepin
2022-05-04 01:19
#6

补充了些文档,有兴趣的直接去啃代码,很简单。

源码在这里: https://gitee.com/outersky/xtray

Reply View the author
(null)
deepin
2022-05-04 14:56
#7
The user is banned, and the content is hidden.