Merge pull request #6 from msmol/master

Added support for pass-otp
master
akermu 9 years ago committed by GitHub
commit 9b9cfb31a7
  1. 7
      README.md
  2. 13
      pass.cpp
  3. 1
      pass.h

@ -3,6 +3,13 @@ Krunner pass
Integrates [krunner](https://userbase.kde.org/Plasma/Krunner) with [pass](https://www.passwordstore.org).
## Use with [pass-otp](https://github.com/tadfisher/pass-otp)
To use with pass-otp, use the identifier "totp::" as a prefix in the filename or file path of the otp password file.
Alternatively, set $PASSWORD_STORE_OTP_IDENTIFIER to overwrite the identifier string. This must be set in `.xprofile`
or similar file, before the initalization of krunner.
Build and Installation
======================

@ -61,6 +61,12 @@ void Pass::init() {
}
}
this->passOtpIdentifier = "totp::";
auto passOtpIdentifier = getenv("PASSWORD_STORE_OTP_IDENTIFIER");
if (passOtpIdentifier != nullptr) {
this->passOtpIdentifier = passOtpIdentifier;
}
initPasswords();
connect(&watcher, SIGNAL(directoryChanged(QString)), this, SLOT(reinitPasswords(QString)));
@ -125,7 +131,12 @@ void Pass::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &m
{
Q_UNUSED(context);
auto ret = QProcess::execute(QString("pass -c ") + match.text());
auto regexp = QRegularExpression("^" + QRegularExpression::escape(this->passOtpIdentifier) + ".*");
auto isOtp = match.text().split('/').filter(regexp).size() > 0;
auto ret = isOtp ?
QProcess::execute(QString("pass otp -c ") + match.text()) :
QProcess::execute(QString("pass -c ") + match.text());
if (ret == 0) {
QString msg = i18n("Password %1 copied to clipboard for %2 seconds", match.text(), timeout);
KNotification::event("password-unlocked", "Pass", msg,

@ -44,6 +44,7 @@ protected:
private:
QDir baseDir;
QString passOtpIdentifier;
int timeout;
QReadWriteLock lock;
QList<QString> passwords;

Loading…
Cancel
Save