diff options
author | Klemens Nanni <klemens@posteo.de> | 2022-06-24 17:59:06 +0300 |
---|---|---|
committer | Jonathan White <support@dmapps.us> | 2022-09-05 19:23:50 +0300 |
commit | 14f12b0a25c7e9356910128daf60c0ba78596e1e (patch) | |
tree | 97e290afa43bb4cc9e54629e988f47d7826d1c48 | |
parent | e05f6a4c5b71f47aa262ec1571c822a59656f76e (diff) |
autostart: Linux: Exec= filename not absolute path
Systems like NixOS install software under unique paths, so persisting
the absolute file path in the generated .desktop file when enabling
autostart will eventually point at an outdated or nonexistent program.
Another possible issue with using Qt's `applicationFilePath()` is that
the final program's basename (`argv[0]`) might not be the same as what
the user initially executed to start KeePassXC.
Use the file name and thus rely on `PATH` lookup just like the static
.desktop file does to lift those issues and defer execution logic
(`PATH` lookup, wrapper scripts, etc.) to the operating system.
-rw-r--r-- | src/gui/osutils/nixutils/NixUtils.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/gui/osutils/nixutils/NixUtils.cpp b/src/gui/osutils/nixutils/NixUtils.cpp index d0fa84f3c..ba44cd273 100644 --- a/src/gui/osutils/nixutils/NixUtils.cpp +++ b/src/gui/osutils/nixutils/NixUtils.cpp @@ -128,15 +128,15 @@ void NixUtils::setLaunchAtStartup(bool enable) const QString appImagePath = QString::fromLocal8Bit(qgetenv("APPIMAGE")); const bool isAppImage = !appImagePath.isNull() && QFile::exists(appImagePath); - const QString executeablePath = isAppImage ? appImagePath : QApplication::applicationFilePath(); + const QString executeablePathOrName = isAppImage ? appImagePath : QApplication::applicationName().toLower(); 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=") << executeablePath << '\n' - << QStringLiteral("TryExec=") << executeablePath << '\n' + << QStringLiteral("Exec=") << executeablePathOrName << '\n' + << QStringLiteral("TryExec=") << executeablePathOrName << '\n' << QStringLiteral("Icon=") << QApplication::applicationName().toLower() << '\n' << QStringLiteral("StartupWMClass=keepassxc") << '\n' << QStringLiteral("StartupNotify=true") << '\n' |