Skip to content

Commit

Permalink
fix: Fixed the default path issue
Browse files Browse the repository at this point in the history
Fixed the default path issue
Bug: https://pms.uniontech.com/bug-view-272475.html
Log: Fixed the default path issue
  • Loading branch information
pengfeixx committed Nov 28, 2024
1 parent d1c60f6 commit 45d611a
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <QDir>
#include <QDebug>
#include <QProcess>
#include <QCommandLineParser>
#include <QTranslator>
#include <QTime>
Expand All @@ -28,8 +29,39 @@ DCORE_USE_NAMESPACE

Q_DECLARE_LOGGING_CATEGORY(mainprocess)

bool checkImmutableMode() {
QProcess process;
QStringList arguments;
arguments << "-s"; // 命令参数

// 启动进程并等待其完成
process.start("deepin-immutable-ctl", arguments);
if (!process.waitForStarted()) {
qWarning() << "Failed to start deepin-immutable-ctl:" << process.errorString();
return false;
}

if (!process.waitForFinished()) {
qWarning() << "deepin-immutable-ctl did not finish successfully:" << process.errorString();
return false;
}

// 获取命令输出
QByteArray output = process.readAllStandardOutput();
QString result = QString::fromUtf8(output.trimmed());
if (result.split(":").at(1) == "true") {
qInfo() << "System is in immutable mode.";
return true;
} else {
qInfo() << "System is not in immutable mode. Output was:" << result;
return false;
}
}

int main(int argc, char *argv[])
{
if (checkImmutableMode())
setenv("PWD", getenv("HOME"), 1);
if (!QString(qgetenv("XDG_CURRENT_DESKTOP")).toLower().startsWith("deepin")) {
setenv("XDG_CURRENT_DESKTOP", "Deepin", 1);
}
Expand Down

0 comments on commit 45d611a

Please sign in to comment.