Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dunst: set per-app notification icons #2005

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
39 changes: 33 additions & 6 deletions Configs/.config/dunst/dunst.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
# will be ignored.
follow = mouse

# When set to true (recommended), you can use POSIX regular expressions for filtering rules.
# It uses the POSIX Extended Regular Expression syntax: https://en.m.wikibooks.org/wiki/Regular_Expressions/POSIX-Extended_Regular_Expressions.
#
# If this is set to false (not recommended), dunst will us fnmatch(3) for matching strings.
# Dunst doesn't pass any flags to fnmatch, so you cannot make use of extended patterns.
enable_posix_regex = true

### Geometry ###

# dynamic width from 0 to 300
Expand Down Expand Up @@ -198,10 +205,9 @@

# Recursive icon lookup. You can set a single theme, instead of having to
# define all lookup paths.
#enable_recursive_icon_lookup = true
enable_recursive_icon_lookup = true

# Set icon theme (only used for recursive icon lookup)
#icon_theme = Adwaita
# You can also set multiple icon themes, with the leftmost one being used first.
icon_theme = "Tela-circle-dracula"

Expand All @@ -211,14 +217,11 @@
# Scale small icons up to this size, set to 0 to disable. Helpful
# for e.g. small files or high-dpi screens. In case of conflict,
# max_icon_size takes precedence over this.
min_icon_size = 32
min_icon_size = 128

# Scale larger icons down to this size, set to 0 to disable
max_icon_size = 128

# Paths to default icons (only necessary when not using recursive icon lookup)
icon_path = $HOME/.icons/Tela-circle-dracula/16/actions:$HOME/.icons/Tela-circle-dracula/16/apps:$HOME/.icons/Tela-circle-dracula/16/devices:$HOME/.icons/Tela-circle-dracula/16/mimetypes:$HOME/.icons/Tela-circle-dracula/16/panel:$HOME/.icons/Tela-circle-dracula/16/places:$HOME/.icons/Tela-circle-dracula/16/status

### History ###

# Should a notification popped up from history be sticky or timeout
Expand Down Expand Up @@ -447,3 +450,27 @@
frame_color = "#f38ba8"
icon = "$HOME/.config/dunst/icons/critical.svg"
timeout = 0

[slack]
desktop_entry = "^Slack$"
new_icon = slack

[telegram]
desktop_entry = "^Telegram Desktop$"
new_icon = telegram-desktop

[skype]
desktop_entry = "^Skype$"
new_icon = skype

[discord]
desktop_entry = "^Discord$"
new_icon = discord

[zapzap]
desktop_entry = "^ZapZap$"
new_icon = whatsapp

[viber]
desktop_entry = "^Viber$"
new_icon = viber
14 changes: 9 additions & 5 deletions Configs/.config/dunst/dunstrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
# will be ignored.
follow = mouse

# When set to true (recommended), you can use POSIX regular expressions for filtering rules.
# It uses the POSIX Extended Regular Expression syntax: https://en.m.wikibooks.org/wiki/Regular_Expressions/POSIX-Extended_Regular_Expressions.
#
# If this is set to false (not recommended), dunst will us fnmatch(3) for matching strings.
# Dunst doesn't pass any flags to fnmatch, so you cannot make use of extended patterns.
enable_posix_regex = true

### Geometry ###

# dynamic width from 0 to 300
Expand Down Expand Up @@ -198,7 +205,7 @@

# Recursive icon lookup. You can set a single theme, instead of having to
# define all lookup paths.
#enable_recursive_icon_lookup = true
enable_recursive_icon_lookup = true

# Set icon theme (only used for recursive icon lookup)
#icon_theme = Adwaita
Expand All @@ -211,14 +218,11 @@
# Scale small icons up to this size, set to 0 to disable. Helpful
# for e.g. small files or high-dpi screens. In case of conflict,
# max_icon_size takes precedence over this.
min_icon_size = 32
min_icon_size = 128

# Scale larger icons down to this size, set to 0 to disable
max_icon_size = 128

# Paths to default icons (only necessary when not using recursive icon lookup)
icon_path = $HOME/.icons/Tela-circle-dracula/16/actions:$HOME/.icons/Tela-circle-dracula/16/apps:$HOME/.icons/Tela-circle-dracula/16/devices:$HOME/.icons/Tela-circle-dracula/16/mimetypes:$HOME/.icons/Tela-circle-dracula/16/panel:$HOME/.icons/Tela-circle-dracula/16/places:$HOME/.icons/Tela-circle-dracula/16/status

### History ###

# Should a notification popped up from history be sticky or timeout
Expand Down
47 changes: 39 additions & 8 deletions Configs/.local/share/bin/themeswitch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,26 @@ Theme_Change()
done
}

get_gtk_theme()
{
local themeDir=$1
echo "$({ grep -q "^[[:space:]]*\$GTK[-_]THEME\s*=" "${themeDir}/hypr.theme" && grep "^[[:space:]]*\$GTK[-_]THEME\s*=" "${themeDir}/hypr.theme" | cut -d '=' -f2 | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' ;} ||
grep 'gsettings set org.gnome.desktop.interface gtk-theme' "${themeDir}/hypr.theme" | awk -F "'" '{print $((NF - 1))}')"
}

get_icon_theme()
{
local themeDir=$1
echo "$({ grep -q "^[[:space:]]*\$ICON[-_]THEME\s*=" "${themeDir}/hypr.theme" && grep "^[[:space:]]*\$ICON[-_]THEME\s*=" "${themeDir}/hypr.theme" | cut -d '=' -f2 | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' ;} ||
grep 'gsettings set org.gnome.desktop.interface icon-theme' "${themeDir}/hypr.theme" | awk -F "'" '{print $(NF - 1)}')"
}

join_array()
{
local IFS="$1"
shift
echo "$*"
}

#// evaluate options

Expand Down Expand Up @@ -70,15 +90,10 @@ source "${scrDir}/globalcontrol.sh"
#// hypr
[ -n "$HYPRLAND_INSTANCE_SIGNATURE" ] && hyprctl keyword misc:disable_autoreload 1 -q
sed '1d' "${hydeThemeDir}/hypr.theme" > "${confDir}/hypr/themes/theme.conf" # Useless and already handled by swwwallbash.sh but kept for robustness
gtkTheme="$(
{ grep -q "^[[:space:]]*\$GTK[-_]THEME\s*=" "${hydeThemeDir}/hypr.theme" && grep "^[[:space:]]*\$GTK[-_]THEME\s*=" "${hydeThemeDir}/hypr.theme" | cut -d '=' -f2 | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' ;} ||
grep 'gsettings set org.gnome.desktop.interface gtk-theme' "${hydeThemeDir}/hypr.theme" | awk -F "'" '{print $((NF - 1))}'
)"

gtkIcon="$(
{ grep -q "^[[:space:]]*\$ICON[-_]THEME\s*=" "${hydeThemeDir}/hypr.theme" && grep "^[[:space:]]*\$ICON[-_]THEME\s*=" "${hydeThemeDir}/hypr.theme" | cut -d '=' -f2 | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' ;} ||
grep 'gsettings set org.gnome.desktop.interface icon-theme' "${hydeThemeDir}/hypr.theme" | awk -F "'" '{print $(NF - 1)}'
)"
gtkTheme=$(get_gtk_theme "$hydeThemeDir")
gtkIcon=$(get_icon_theme "$hydeThemeDir")


#// qtct

Expand Down Expand Up @@ -115,6 +130,22 @@ if pkg_installed flatpak ; then
fi
fi


#// dunst

unset iconThemes
while read thmDir ; do
if [ "$(basename "${thmDir}")" == "${hydeTheme}" ] ; then
continue
fi
iconThemes+=($(get_icon_theme "$thmDir"))
done < <(find "${hydeConfDir}/themes" -mindepth 1 -maxdepth 1 -type d)
iconThemes=(${gtkIcon} "${iconThemes[*]}")
iconThemesConcat=$(join_array "," ${iconThemes[*]})

sed -i "/^ icon_theme =/c\ icon_theme = \"${iconThemesConcat}\"" "${confDir}/dunst/dunst.conf"


#// wallpaper

"${scrDir}/swwwallpaper.sh" -s "$(readlink "${hydeThemeDir}/wall.set")"
Expand Down
1 change: 0 additions & 1 deletion Configs/.local/share/bin/wallbashdunst.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ envsubst < "${dstDir}/dunst.conf" > "${dstDir}/dunstrc"
envsubst < "${dstDir}/wallbash.conf" >> "${dstDir}/dunstrc"
killall dunst
dunst &