linux - 如何获取当前系统主题的图标集?

标签 linux bash shell icons

我正在编写一个 bash 脚本,它使用 notify-send(来自 notify-osd 包)向用户显示弹出通知,例如如果在运行期间出现错误。这些弹出窗口可以用图标装饰,如下所示:

notify-send -i $icon $headline $message

为了让我的脚本尽可能精简,我想使用系统自带的默认图标。到目前为止,我已经采用硬编码文件名,如下所示:

icon="/usr/share/icons/Mint-Y/status/48/dialog-error.png"

这显然是一个非常糟糕的解决方案,因为图标所依赖的主题可能未安装在给定系统上(在上面的示例中,它是“Mint Y”主题)。我正在寻找一种方法来告诉我的脚本:“向系统询问当前设置的图标主题中的错误图标,然后使用它。”

问题是:我该怎么做?

最佳答案

不要指定路径之类的东西。您应该指定通用文件名片段,并让系统为您搜索最佳值。

因此,如果文件名中有大小或文件类型或其他内容,请将其删除,并且不要指定前导路径。

使用类似notify-send -i info testnotify-send -i error test ...

或者 notify-send -i printer-error test,它会找到像 /usr/share/icons/Adwaita/256x256/status/printer-error.png 这样的东西 引擎盖下。

关于linux - 如何获取当前系统主题的图标集?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57022937/

相关文章:

c - 如何为新文件创建补丁?

c - 停止客户端服务器程序

shell - 如何在Makefile中设置子进程的环境变量

perl - 在 Unix 中排序日期/时间

linux - Grep Only 返回第一个匹配结果(不需要)。我该如何防止这种情况?

linux - centos服务器上的定时任务

linux - shell 脚本 : How to enforce display of previous query if a statement is true?

linux - 在 bash 中比较 *nix 时间戳的最佳方法

linux - grep : can't open/Data. 配置文件

linux - rpm --test 从不返回非空字符串?