xfce / bash:shell 脚本中的 gui 元素

xfce / bash:shell 脚本中的 gui 元素

我有一个最小安装,默认窗口管理器是 xfce。是否可以编写一个包含简单 gui 元素的 shell 脚本?或者我是否要安装其他东西(我不太愿意这样做,我想将安装的软件包数量(大小)保持在最低限度)。

答案1

尝试 Zenity:

" Zenity allows you to display GTK+ dialogs from shell scripts".

它非常简单,这里是依赖项,其中许多应该已经存在于 xfce 系统上:

Depends: libc6 (>= 2.4), libgdk-pixbuf2.0-0 (>= 2.22.0), libglib2.0-0 (>= 2.24.0), libgtk-3-0 (>= 3.0.0), libnotify4 (>= 0.7.0), libpango1.0-0 (>= 1.14.0), libwebkitgtk-3.0-0 (>= 1.3.10), libx11-6, zenity-common (= 3.2.0-0ubuntu1)

答案2

另一个选择是yad

 YAD  is a program that will display GTK+ dialogs, and return (either in
       the return code or on standard output) the users input. This allows you
       to present information, and ask for information from the user, from all
       manner of shell scripts.

       YAD is the fork of Zenity program.

YAD(Yet Another Dialog)是 Zenity 的一个分支,具有许多改进,例如自定义按钮、附加对话框、通知图标中的弹出菜单等。基本上,您想在 Zenity 中执行的大部分操作都可以在 YAD 中找到:您可以拥有任意数量的按钮,每个按钮都带有您想要的文本,还有一个非常漂亮的图标对话框。

YAD 没有所有相同的对话框,例如 --error、--info、--question 或 --warning - 相反,它有一个 --form 对话框,您可以在其中添加任何您想要的消息、按钮和图标。它还包括 --notification 对话框,以便在通知区域中显示图标。有关使用 YAD 的帮助,请参阅其 [Wiki] 中的示例部分(https://code.google.com/archive/p/yad/wikis/Examples.wiki

yad可以在所有当前支持的 Ubuntu 版本的存储库中找到,尽管像许多这些有用的软件包一样,你必须启用 Universe 存储库如果在尝试安装之前尚未启用它。

资料来源:

man yad

http://www.webupd8.org/2010/12/yad-zenity-on-steroids-display.html

https://code.google.com/archive/p/yad/wikis/Examples.wiki

https://www.mankier.com/1/yad

相关内容