diff --git a/scripts/snap-wrapper.sh b/scripts/snap-wrapper.sh index 9e45e91..0122ad3 100755 --- a/scripts/snap-wrapper.sh +++ b/scripts/snap-wrapper.sh @@ -33,6 +33,6 @@ export LD_LIBRARY_PATH="$SNAP_LIBRARY_PATH:$LD_LIBRARY_PATH" # create all our application launchers in. The system application launcher will # be configured by our installer to look into this directory for available # launchers. -export XDG_DATA_HOME="$SNAP_USER_COMMON" +export XDG_DATA_HOME="$SNAP_USER_COMMON/app-data" exec $SNAP/usr/bin/anbox $@ diff --git a/src/anbox/application/launcher_storage.cpp b/src/anbox/application/launcher_storage.cpp index cb8f5f1..a94602d 100644 --- a/src/anbox/application/launcher_storage.cpp +++ b/src/anbox/application/launcher_storage.cpp @@ -25,6 +25,12 @@ namespace fs = boost::filesystem; +namespace { +// This will always point us to the right executable when we're running within +// a snap environment. +constexpr const char *snap_exe_path{"/snap/bin/anbox"}; +} + namespace anbox { namespace application { LauncherStorage::LauncherStorage(const fs::path &path, @@ -62,7 +68,11 @@ void LauncherStorage::add_or_update(const Item &item) { auto package_name = item.package; std::replace(package_name.begin(), package_name.end(), '.', '-'); - std::string exec = utils::string_format("%s launch ", utils::process_get_exe_path(getpid())); + auto exe_path = utils::process_get_exe_path(getpid()); + if (utils::get_env_value("SNAP").length() > 0) + exe_path = snap_exe_path; + + std::string exec = utils::string_format("%s launch ", exe_path); if (!item.launch_intent.action.empty()) exec += utils::string_format("--action=%s ", item.launch_intent.action); diff --git a/src/anbox/cmds/system_info.cpp b/src/anbox/cmds/system_info.cpp index 372bc0a..421f11c 100644 --- a/src/anbox/cmds/system_info.cpp +++ b/src/anbox/cmds/system_info.cpp @@ -195,7 +195,7 @@ anbox::cmds::SystemInfo::SystemInfo() : CommandWithFlagsAndAction{ cli::Name{"system-info"}, cli::Usage{"system-info"}, cli::Description{"Print various information about the system we're running on"}} { - action([](const cli::Command::Context& ctxt) { + action([](const cli::Command::Context&) { SystemInformation si; std::cout << si; return EXIT_SUCCESS;