mirror of
https://github.com/audacity/linuxdeploy.git
synced 2026-04-16 21:51:43 -05:00
Use -n parameter to enhance search for suitable desktop file
In case there's more than a desktop file, the user can specify the app name using -n <app name>, and linuxdeploy will try to find a suitable desktop file whose filename starts with the specified app name.
This commit is contained in:
26
src/main.cpp
26
src/main.cpp
@@ -11,9 +11,11 @@
|
||||
#include "linuxdeploy/core/elf.h"
|
||||
#include "linuxdeploy/core/log.h"
|
||||
#include "linuxdeploy/plugin/plugin.h"
|
||||
#include "util.h"
|
||||
|
||||
using namespace linuxdeploy::core;
|
||||
using namespace linuxdeploy::core::log;
|
||||
using namespace linuxdeploy::util;
|
||||
|
||||
namespace bf = boost::filesystem;
|
||||
|
||||
@@ -245,10 +247,32 @@ int main(int argc, char** argv) {
|
||||
|
||||
auto deployedDesktopFiles = appDir.deployedDesktopFiles();
|
||||
|
||||
desktopfile::DesktopFile desktopFile;
|
||||
|
||||
if (deployedDesktopFiles.empty()) {
|
||||
ldLog() << LD_WARNING << "Could not find desktop file in AppDir, cannot create links for AppRun, desktop file and icon in AppDir root" << std::endl;
|
||||
} else {
|
||||
auto& desktopFile = deployedDesktopFiles[0];
|
||||
if (!appName.Get().empty()) {
|
||||
auto desktopFileMatchingName = std::find_if(
|
||||
deployedDesktopFiles.begin(),
|
||||
deployedDesktopFiles.end(),
|
||||
[&appName](const desktopfile::DesktopFile& desktopFile) {
|
||||
auto fileName = desktopFile.path().filename().string();
|
||||
return stringStartsWith(fileName, appName.Get()) && stringEndsWith(fileName, ".desktop");
|
||||
}
|
||||
);
|
||||
|
||||
if (desktopFileMatchingName != deployedDesktopFiles.end()) {
|
||||
desktopFile = *desktopFileMatchingName;
|
||||
ldLog() << "Found desktop file matching app name:" << desktopFile.path() << std::endl;
|
||||
} else {
|
||||
desktopFile = deployedDesktopFiles[0];
|
||||
ldLog() << LD_WARNING << "Could not find suitable desktop file for given app name" << appName << LD_NO_SPACE << ", using first desktop file found:" << desktopFile.path() << std::endl;
|
||||
}
|
||||
} else {
|
||||
desktopFile = deployedDesktopFiles[0];
|
||||
ldLog() << LD_WARNING << "App name not specified, using first desktop file found:" << desktopFile.path() << std::endl;
|
||||
}
|
||||
|
||||
ldLog() << "Deploying desktop file:" << desktopFile.path() << std::endl;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user