mu-wizard

shell script to easily configure mu4e accounts on Emacs
git clone git://git.ckyln.com/mu-wizard
Log | Files | Refs | LICENSE

commit 405035faccdd9fda1fd0e85e0f48b141c22843cc
parent 662bdabdfb599682a7031d1e30153e744069f73a
Author: Cem Keylan <cem@ckyln.com>
Date:   Wed, 25 May 2022 17:04:45 +0200

notify(): add notification display support for herbe

Diffstat:
Mbin/muw | 21+++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/bin/muw b/bin/muw @@ -331,11 +331,20 @@ getoptions_help() { } out() { printf '%s\n' "$@" >&2 ;} -err() { printf '\033[1m%s\033[m\n' "$@" >&2 ;} +warn() { printf '\033[1;33mWARNING\033[m %s\n' "$@" >&2 ;} +info() { printf '\033[1;36mINFO\033[m %s\n' "$@" >&2 ;} +err() { printf '\033[1mERROR \033[m%s\n' "$@" >&2 ;} die() { err "$@"; exit 1 ;} version() { printf 'mu-wizard version: %s\n' @VERSION@ ;} + notify() { - notify-send -i mail-unread -a "mu-wizard" "$@" + case ${notify_method##*/} in + notify-send) "$notify_method" -i mail-unread -a "mu-wizard" "$@" ;; + herbe) "$notify_method" "$@" ;; + null) info "No notification method found, disabling notifications"; notify_method=disabled ;; + disabled) ;; + *) warn "Notification method '$notify_method' unknown"; notify_method=disabled + esac } prompt() { # The first argument is used as the prompt, and will print as 'prompt: '. @@ -698,6 +707,14 @@ main() { isync_far=Master isync_near=Slave fi + # Set notification program, we support both libnotify, which is the most + # common one out there, and also herbe, which does not depend on dbus. We + # try 'notify-send' first, because its interface is more convenient. + notify_method=${MUW_NOTIFY:-$( + command -v notify-send || + command -v herbe)} || + notify_method=null +} eval "$(getoptions parser_definition parse)" parse "$@"; eval set -- "$REST" action=$1; shift