用于在任务栏上放置图标的 Bash 工具?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20344674/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 08:50:07  来源:igfitidea点击:

Bash tool to put an icon on taskbar?

linuxbash

提问by user1343318

I am trying to create a tiny application on my Ubuntu machine. What I want to do is put to an icon on my taskbar beside the volume, and internet connectivity options. I understand that there is a notify-sendcommand in bash that I can use, or even switch to Qtbut that seems to be an overkill for the problem. Concretely, is there a way to create an icon on Ubuntu taskbar with bash, and change its color or text periodically?

我正在尝试在我的 Ubuntu 机器上创建一个小应用程序。我想要做的是在我的任务栏上的音量和互联网连接选项旁边放置一个图标。我知道notify-send我可以使用 bash 中的一个命令,甚至可以切换到,Qt但这似乎对这个问题来说太过分了。具体来说,有没有办法用 bash 在 Ubuntu 任务栏上创建一个图标,并定期更改其颜色或文本?

回答by memeplex

For a very shell friendly way to quickly get tray apps working use yad(specifically yad --notification). It allows you to dynamically change icons, set click event handlers and build a custom context menu. For example:

要以非常友好的方式快速使托盘应用程序正常工作,请使用yad(特别是yad --notification)。它允许您动态更改图标、设置单击事件处理程序并构建自定义上下文菜单。例如:

yad --notification --command='echo hello world' --image=myicon.png

Will echo 'hello world' on click. Or:

单击时将回显 'hello world'。或者:

yad --notification --command='echo hello world' --image=myicon.png --listen

Will read it's standard input waiting for commands to change icons, change visibility, open menu, trigger action and more.

将读取它的标准输入,等待命令更改图标、更改可见性、打开菜单、触发操作等。

回答by Riccardo Volpe

Take a look at alltray; maybe it's your solution.

看看alltray;也许这是你的解决方案。

From its website:

从它的网站:

Description

With AllTray you can dock any application with no native tray icon (like Evolution, Thunderbird, Terminals) into the system tray. A high-light feature is that a click on the "close" button will minimize back to system tray. It works well with Gnome, KDE, XFCE 4*, Fluxbox* and WindowMaker*. Xmms is supported in particular.

Options

These programs follow the usual GNU command line syntax, with long options starting with two dashes ('-'). A summary of options is included below.

-h --help | Show summary of options.

-v --version | Show version of program.

-d --debug | Show debug messages.

-s --show | Do not hide window after start.

-i --icon | Use a PNG image as an icon.

-l --large_icons | allow large icons (> 24x24).

-st --sticky | visible on all workspaces.

-x --borderless | Remove windows decorations border, title, frame... from parent.

-m --menu | Add entry "menu text:command" to popdown menu.

-t --title | Show title change for seconds. Probably most usefull for xmms.

-g --geometry | initial position. see man X.

描述

使用 AllTray,您可以将任何没有本机托盘图标(如 Evolution、Thunderbird、Terminals)的应用程序停靠到系统托盘中。一个突出的功能是单击“关闭”按钮将最小化回到系统托盘。它适用于 Gnome、KDE、XFCE 4*、Fluxbox* 和 WindowMaker*。特别支持 Xmms。

选项

这些程序遵循通常的 GNU 命令行语法,带有以两个破折号 ('-') 开头的长选项。下面是选项的摘要。

-h --help | 显示选项摘要。

-v --version | 显示程序版本。

-d --debug | 显示调试消息。

-s --show | 启动后不要隐藏窗口。

-i --icon | 使用 PNG 图像作为图标。

-l --large_icons | 允许大图标(> 24x24)。

-st --sticky | 在所有工作区中可见。

-x --无边界 | 从父级中删除窗口装饰边框、标题、框架...。

-m --menu | 将条目“菜单文本:命令”添加到弹出菜单。

-t --title | 显示标题更改几秒钟。可能对 xmms 最有用。

-g --geometry | 初始位置。见人X。

Installation (command in a terminal)

安装(终端中的命令)

- in Ubuntu:

- 在 Ubuntu 中:

sudo apt-get install alltray

- in Fedora:

- 在 Fedora 中:

sudo dnf install alltray

Cheers

干杯