public
Last active

Script for piping IMAP and SMTP passwords from KWallet to mutt.

  • Download Gist
.muttrc
1 2 3 4
#in .muttrc
 
set imap_pass ="`pass.sh mutt 2>&1`"
set smtp_pass ="`pass.sh mutt 2>&1`"
pass.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
#!/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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.