use pid + sequential number in terminal app id (#448)

This commit is contained in:
Cyano Hao 2024-06-05 17:23:17 +08:00 committed by GitHub
parent 26a2f44006
commit d7df8248ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 6 deletions

View File

@ -138,7 +138,7 @@
{
"name": "Elementary Terminal",
"path": "io.elementary.terminal",
"argsPattern": "$term --gapplication-app-id $random_app_id -e \"$unix_command\"",
"argsPattern": "$term --gapplication-app-id $sequential_app_id -e \"$unix_command\"",
"comment": "confirm to quit"
},
{
@ -150,7 +150,7 @@
{
"name": "GNOME Console",
"path": "kgx",
"argsPattern": "$term --gapplication-app-id $random_app_id -- $argv",
"argsPattern": "$term --gapplication-app-id $sequential_app_id -- $argv",
"comment": "confirm to quit"
},
{

View File

@ -4134,7 +4134,7 @@ const QMap<QString, QString> Settings::Environment::mTerminalArgsPatternMagicVar
{"dos_command", "$dos_command"},
{"lpCommandLine", "$lpCommandLine"},
{"tmpfile", "$tmpfile"},
{"random_app_id", "$random_app_id"},
{"sequential_app_id", "$sequential_app_id"},
};
Settings::Executor::Executor(Settings *settings):_Base(settings, SETTING_EXECUTOR)

View File

@ -754,9 +754,10 @@ std::tuple<QString, QStringList, PNonExclusiveTemporaryFileOwner> wrapCommandFor
QFile(temproryFile->fileName()).setPermissions(QFileDevice::ReadOwner | QFileDevice::WriteOwner | QFileDevice::ExeOwner);
}
wrappedArgs.push_back(temproryFile->fileName());
} else if (patternItem == "$random_app_id") {
QString randomSuffix = QString::number(QRandomGenerator::global()->generate());
QString appId = "io.redpanda.term" + randomSuffix;
} else if (patternItem == "$sequential_app_id") {
static QString prefix = QStringLiteral("io.redpanda.term_%1_").arg(QCoreApplication::applicationPid());
static std::atomic<int> appIdCounter = 0;
QString appId = prefix + QString::number(++appIdCounter);
wrappedArgs.push_back(appId);
} else
wrappedArgs.push_back(patternItem);