diff options
author | Lukas Fürmetz <fuermetz@mailbox.org> | 2017-07-17 22:56:46 +0200 |
---|---|---|
committer | Lukas Fürmetz <fuermetz@mailbox.org> | 2017-07-17 22:56:46 +0200 |
commit | e1e42c234fe7402b8c60d7ff5799734a1f5b0ce8 (patch) | |
tree | b72f3a594569dce2334f8da2fc258f7d214072b8 | |
parent | be636296f65c5f27c3debea1b6ea29f7c0974ae1 (diff) |
Fix #9
-rw-r--r-- | pass.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -217,11 +217,25 @@ void Pass::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &m auto regexp = QRegularExpression("^" + QRegularExpression::escape(this->passOtpIdentifier) + ".*"); auto isOtp = match.text().split('/').filter(regexp).size() > 0; - auto ret = isOtp ? - QProcess::execute(QString("pass"), QStringList() << "otp" << "-c" << match.text()) : - QProcess::execute(QString("pass"), QStringList() << "-c" << match.text()); - if (ret == 0) { + QProcess pass; + QStringList args; + if (isOtp) { + args << "otp" << "show" << match.text(); + } else { + args << "show" << match.text(); + } + pass.start("pass", args); + pass.waitForFinished(-1); + auto output = pass.readAllStandardOutput(); + auto string = QString::fromUtf8(output.data()); + auto lines = string.split('\n', QString::SkipEmptyParts); + if (lines.count() > 0) { + QClipboard *cb = QApplication::clipboard(); + cb->setText(lines[0]); this->showNotification(match.text()); + QTimer::singleShot(timeout * 1000, cb, [cb]() { + cb->clear(); + }); } } } |