Dunst: 在 ~/.config/dunstrc 中使用环境变量

创建于 2018-12-08  ·  6评论  ·  资料来源: dunst-project/dunst

我想根据环境变量设置通知的颜色。 代替:

~/.config/dunst/dunstrc

[urgency_low]
    # IMPORTANT: colors have to be defined in quotation marks.
    # Otherwise the "#" and following would be interpreted as a comment.
    background = "#222222"
    foreground = "#888888"
    timeout = 5

我想要做:

~/.config/dunst/dunstrc

[urgency_low]
    # IMPORTANT: colors have to be defined in quotation marks.
    # Otherwise the "#" and following would be interpreted as a comment.
    background = "${DUNST_NORMAL_BACKGROUND}"
    foreground = "${DUNST_NORMAL_FOREGROUND}"
    timeout = 5

~/.profile设置这些环境变量,或者设置可以被 dunst 选取的环境变量的任何源文件。

~/.profile

DUNST_NORMAL_BACKGROUND="#888888"
DUNST_NORMAL_FOREGROUND="#FFFFFF"

这样当我通过`~/.config/i3/config 加载 dunst 时

exec --no-startup-id dunst

然后 dunst 将根据~/.profile设置的内容设置通知的颜色
我想在我所有使用配置文件(i3、polybar、rofi、dunst、白蚁等)的应用程序中集中主题(主要是颜色)。 我的目标是有一个文件来设置环境变量,以便我可以通过采购单个文件来换出主题。

我想采用与此类似的主题并在多个应用程序中应用主题。
https://github.com/arcticicestudio/nord

最有用的评论

好吧,对于简单的变量替换,您可以简单地使用envsubst命令:

envsubst < ~/.config/dunst/dunstrc.template > ~/.config/dunst/dunstrc

所有6条评论

正如您可能已经猜到的那样,目前这是不可能的,我不确定是否要实施它。

但是,您是否查看过 contrib 目录? 我们有一个从 Xresource 值生成dunstrc的脚本,您可以使用它或以某种方式调整它以使用 shell 变量

@tsipinakis我不知道那个脚本。 我运行它并将它创建的文件交换为原始文件,它改变了 dunsts 的颜色,这很有帮助。 在快速阅读它之后,我不明白在确定要覆盖哪些设置时,它希望从 Xresources 读取哪些值。 我会继续阅读它,直到它有道理为止。

我希望 dunst 支持环境变量或将配置导入主配置。 剧本是个好主意,我会试一试。

我正在尝试创建一个由键盘驱动的工具组成的桌面环境,并使用配置文件进行配置,这很容易在一个位置进行配置。 主题是我的清单上剩下的少数要解决的问题之一。 有兴趣的可以在这里查看源代码! :)

好吧,对于简单的变量替换,您可以简单地使用envsubst命令:

envsubst < ~/.config/dunst/dunstrc.template > ~/.config/dunst/dunstrc

@bebehei哇我不知道存在。 太棒了! 谢谢你的建议!

所以,我认为显而易见的解决方案是使用envsubst 。 对于任何其他值,请咨询#357

@bebehei 太棒了! 谢谢。
我现在正在使用这个:

#~/.xinitrc

#Use bash instead of sh so we can use bashisms
if [[ x"$BASH" != x"/bin/bash" ]]; then
  exec /bin/bash "$HOME/.xinitrc"
fi
dunst -config <(envsubst < ~/.config/dunst/dunstrc) &
此页面是否有帮助?
0 / 5 - 0 等级

相关问题

wpovell picture wpovell  ·  5评论

ahjstone picture ahjstone  ·  4评论

knopwob picture knopwob  ·  5评论

meribold picture meribold  ·  5评论

mrmoroshkin picture mrmoroshkin  ·  4评论