From 031f31f83f5ed97798c68882c65bfafc4bf3f4c2 Mon Sep 17 00:00:00 2001 From: Farnbacher Date: Fri, 8 Jan 2021 19:17:52 +0100 Subject: [PATCH] Use AppImage path for startup on login Fixes #5050 --- src/gui/osutils/nixutils/NixUtils.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gui/osutils/nixutils/NixUtils.cpp b/src/gui/osutils/nixutils/NixUtils.cpp index 769166fe0..d412aa813 100644 --- a/src/gui/osutils/nixutils/NixUtils.cpp +++ b/src/gui/osutils/nixutils/NixUtils.cpp @@ -92,13 +92,18 @@ void NixUtils::setLaunchAtStartup(bool enable) qWarning("Failed to create autostart desktop file."); return; } + + const QString appImagePath = QString::fromLocal8Bit(qgetenv("APPIMAGE")); + const bool isAppImage = !appImagePath.isNull() && QFile::exists(appImagePath); + const QString executeablePath = isAppImage ? appImagePath : QApplication::applicationFilePath(); + QTextStream stream(&desktopFile); stream.setCodec("UTF-8"); stream << QStringLiteral("[Desktop Entry]") << '\n' << QStringLiteral("Name=") << QApplication::applicationDisplayName() << '\n' << QStringLiteral("GenericName=") << tr("Password Manager") << '\n' - << QStringLiteral("Exec=") << QApplication::applicationFilePath() << '\n' - << QStringLiteral("TryExec=") << QApplication::applicationFilePath() << '\n' + << QStringLiteral("Exec=") << executeablePath << '\n' + << QStringLiteral("TryExec=") << executeablePath << '\n' << QStringLiteral("Icon=") << QApplication::applicationName().toLower() << '\n' << QStringLiteral("StartupWMClass=keepassxc") << '\n' << QStringLiteral("StartupNotify=true") << '\n'