Last active
June 9, 2016 17:44
-
-
Save ironhouzi/5464357 to your computer and use it in GitHub Desktop.
Script for piping IMAP and SMTP passwords from KWallet to mutt.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#in .muttrc | |
set imap_pass ="`pass.sh mutt 2>&1`" | |
set smtp_pass ="`pass.sh mutt 2>&1`" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# | |
# Modified version of script created by: | |
# Nick Cross | |
# | |
# Credits : found a lot here | |
# http://learnonthejob.blogspot.com/2009/11/accessing-kde-wallet-from-cmdline.html | |
# | |
# Here the variable KEY is set by the parameter given to this script | |
KEY=$1 | |
WALLETID=$(qdbus org.kde.kwalletd /modules/kwalletd org.kde.KWallet.open kdewallet 0 $KEY) | |
PASSWORD=$(qdbus org.kde.kwalletd /modules/kwalletd readPassword $WALLETID Passwords $KEY $KEY) | |
#By default assume that the password was fetched from KDE Wallet | |
PASSWORD_FETCHED=-1 | |
if [ -z "$PASSWORD" ]; then | |
PASSWORD=$(kdialog --title "Mutt IMAP Password" --password "Please enter passphrase for IMAP account") | |
PASSWORD_FETCHED=$? | |
fi | |
checkKinit() | |
{ | |
while read data | |
do | |
if [ -n "$data" ] | |
then | |
kdialog --title "Kerberos Credentials Error" --error "$data" | |
exit 1 | |
fi | |
done | |
} | |
if [ $? != "1" ] | |
then | |
if [ -z "$PASSWORD" ] | |
then | |
kdialog --error "Blank password; unable to open IMAP account" | |
exit 1 | |
elif [ "$PASSWORD_FETCHED" != "-1" ]; then | |
qdbus org.kde.kwalletd /modules/kwalletd writePassword $WALLETID Passwords $KEY $PASSWORD $KEY | |
if [ $? = 1 ] | |
then | |
kdialog --error "Password fail" | |
fi | |
fi | |
echo $PASSWORD | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment