55 lines
1.4 KiB
Bash
Executable File
55 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# == USER DEFINED LOGOS ==
|
|
declare -A logo_map=(
|
|
["signal"]="/usr/share/icons/hicolor/32x32/apps/signal-desktop.png"
|
|
["mattermost"]="/usr/share/icons/hicolor/32x32/apps/mattermost-desktop.png"
|
|
)
|
|
|
|
|
|
# == CONST ==
|
|
icon_theme="Paper"
|
|
|
|
dunstctl history | jq -cr '.data[0][] | map(.data) | @tsv' | sed 's/\t/|/g' |
|
|
while IFS="|" read -r body message summary appname category defaut_action_name icon_path id timestamp timeout progress
|
|
do
|
|
if [[ $summary == "" || $summary == 'null' ]]; then
|
|
continue
|
|
fi
|
|
|
|
# Fix for Brave
|
|
if [[ $appname == "Brave" ]]; then
|
|
swap=$(sed 's|</\?\(a\)[^>]*>||gm' <<< "$body")
|
|
body=$summary
|
|
summary=$swap
|
|
fi
|
|
|
|
output="${id}: <b>${summary}</b>"
|
|
|
|
if [[ $appname != "" && $appname != 'null' ]]; then
|
|
output="${output} <span weight='light' size='small'><i>(${appname})</i></span>"
|
|
|
|
if [[ $icon_path == "" || $icon_path == 'null' ]]; then
|
|
lc_appname=$(echo "$appname" | tr '[:upper:]' '[:lower:]')
|
|
|
|
if [[ $icon_path == "" ]] || [ ! -f $icon_path ]; then
|
|
icon_path="${logo_map[$lc_appname]}"
|
|
fi
|
|
if [[ $icon_path == "" ]] || [ ! -f $icon_path ]; then
|
|
icon_path="/usr/share/icons/${icon_theme}/32x32/apps/${lc_appname}.png"
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
if [[ $body != "" && $body != 'null' ]]; then
|
|
output="${output}\n${body}"
|
|
fi
|
|
|
|
if [[ $icon_path != "" && $icon_path != 'null' ]]; then
|
|
output="${output}\0icon\x1f${icon_path}"
|
|
fi
|
|
|
|
echo -en "${output}|"
|
|
done
|
|
exit 0
|