summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/namereplace.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/namereplace.cpp b/src/namereplace.cpp
index cc93025..0e203f3 100644
--- a/src/namereplace.cpp
+++ b/src/namereplace.cpp
@@ -4,8 +4,10 @@
#include <QFile>
#include <QTextStream>
#include <QDebug>
+#include <QProcess>
#define SOURCE_FILE "/opt/openslx/lightdm/login-regexp"
+#define LOOKUP_PROCESS "/opt/openslx/pam/get_username"
static QList< QPair< QRegularExpression, QString > > list;
@@ -61,9 +63,22 @@ void NameReplace::loadSubs()
void NameReplace::replace(QString& input)
{
- if (list.isEmpty())
- return;
- for (auto &brumm : list) {
- input = input.replace(brumm.first, brumm.second);
+ if (!list.isEmpty()) {
+ for (auto &brumm : list) {
+ input = input.replace(brumm.first, brumm.second);
+ }
+ }
+ QProcess getCaps;
+ getCaps.start(LOOKUP_PROCESS, QStringList(input));
+ getCaps.waitForFinished(100);
+ QString output = QString::fromLocal8Bit(getCaps.readAllStandardOutput());
+ int idx = output.indexOf('\n');
+ if (idx != -1) {
+ output = output.left(idx);
+ }
+ if (output.length() == input.length()) {
+ input = output;
+ } else {
+ qDebug() << "Not replacing" << input << "by" << output;
}
}