Skip to content

Commit

Permalink
Dunstrun - Use standard configuration file location
Browse files Browse the repository at this point in the history
If dbus-daemon starts dunst instead of this script, the colors/positioning will
still work (though they might be slightly outdated).  Changes are still
necessary so that dunstrun will work if dbus-daemon started dunst first (not
sure how to detect that... could maybe kill the dbus-daemon started dunst if
dunst fails to start).
  • Loading branch information
noctuid committed Nov 27, 2022
1 parent 587af0d commit 1d1242e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
# automatically generated by post-install script
packages.sls
custom.el
# using a template
dunstrc
File renamed without changes.
25 changes: 14 additions & 11 deletions scripts/bin/dunstrun
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,23 @@ monitor_width=$(monitor_get_width)
width=$(monitor_fraction_of 0.2 "$monitor_width")

if [[ -f ~/.cache/wal/dunstrc ]]; then
cat ~/.config/dunst/dunstrc ~/.cache/wal/dunstrc \
~/.config/dunst/overrides_dunstrc > /tmp/dunstrc
cat ~/.config/dunst/dunstrc_template ~/.cache/wal/dunstrc \
~/.config/dunst/overrides_dunstrc > ~/.config/dunst/dunstrc
else
cat ~/.config/dunst/dunstrc ~/.config/dunst/colors_dunstrc \
~/.config/dunst/overrides_dunstrc > /tmp/dunstrc
cat ~/.config/dunst/dunstrc_tumplate ~/.config/dunst/colors_dunstrc \
~/.config/dunst/overrides_dunstrc > ~/.config/dunst/dunstrc
fi

# dunst doesn't allow duplicate headings; use sed to replace placeholder width
sed -i -E -e "s/^\s*(frame_width )=.*/\1= $WM_BORDER/g" /tmp/dunstrc
sed -i -E -e "s/^\s*(width )=.*/\1= $width/g" /tmp/dunstrc
sed -i -E -e "s/^\s*(frame_width )=.*/\1= $WM_BORDER/g" ~/.config/dunst/dunstrc
sed -i -E -e "s/^\s*(width )=.*/\1= $width/g" ~/.config/dunst/dunstrc
# max height
sed -i -E -e "s/^\s*(height )=.*/\1= $width/g" /tmp/dunstrc
sed -i -E -e "s/^\s*(offset )=.*/\1= ${right_offset}x$padding/g" /tmp/dunstrc
sed -i -E -e "s/^\s*(corner_radius )=.*/\1 = $CORNER_RADIUS/g" /tmp/dunstrc
sed -i -E -e "s/^\s*(separator_height )=.*/\1= $HALF_WM_BORDER/g" /tmp/dunstrc
sed -i -E -e "s/^\s*(height )=.*/\1= $width/g" ~/.config/dunst/dunstrc
sed -i -E -e "s/^\s*(offset )=.*/\1= ${right_offset}x$padding/g" \
~/.config/dunst/dunstrc
sed -i -E -e "s/^\s*(corner_radius )=.*/\1 = $CORNER_RADIUS/g" \
~/.config/dunst/dunstrc
sed -i -E -e "s/^\s*(separator_height )=.*/\1= $HALF_WM_BORDER/g" \
~/.config/dunst/dunstrc

xrestart dunst -config /tmp/dunstrc &> /tmp/dunst.log
xrestart dunst &> /tmp/dunst.log

0 comments on commit 1d1242e

Please sign in to comment.