Print message if no found contact

This commit is contained in:
Jeremy Gardais 2020-03-18 15:40:17 +01:00
parent 4d900c53ba
commit 556a4fd2db
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 15 additions and 7 deletions

View File

@ -39,14 +39,22 @@ case "$#" in
esac esac
# ]]] # ]]]
debug_message "Look for a contact with these informations:\n${contact_pattern}" debug_message " Look for a contact with these informations:\n${contact_pattern}"
contact_line=$(khard email "${contact_pattern}" | sed -n 2p) {
debug_message "Matching contact:\n${contact_line}" contact_line=$(khard email "${contact_pattern}" | sed -n 2p)
} > /dev/null
contact_mail=$(printf '%s' "${contact_line}" | awk '{print $NF}') if [ -n "${contact_line}" ]; then
debug_message "Mail of this contact:\n${contact_mail}" debug_message "Matching contact:\n${contact_line}"
# Print the message to X11 contact_mail=$(printf '%s' "${contact_line}" | awk '{print $NF}')
printf '%s' "${contact_mail}" | xdotool type --clearmodifiers --file - debug_message "Mail of this contact:\n${contact_mail}"
else
debug_message " Found no email addresses corresponding to the argument(s)."
contact_mail="NO_CONTACT"
fi
# Print the message to X11
printf '%s' "${contact_mail}" | xdotool type --clearmodifiers --file -
exit 0 exit 0