@@ -96,10 +96,12 @@ namespace {
9696
9797 const fs::path root = fs::temp_directory_path () / (" noctalia-appimage-origin-" + std::to_string (getpid ()));
9898 const fs::path applications = root / " data/applications" ;
99+ const fs::path systemApplications = root / " system/applications" ;
99100 const fs::path executable = root / " PortableApp" ;
100101 const fs::path bin = root / " bin" ;
101102 const fs::path workingDirectory = root / " cwd" ;
102103 fs::create_directories (applications);
104+ fs::create_directories (systemApplications);
103105 fs::create_directories (bin);
104106 fs::create_directories (workingDirectory);
105107 {
@@ -131,6 +133,7 @@ namespace {
131133 binary << " #!/bin/sh\n exit 0\n " ;
132134 chmod ((bin / " native-app" ).c_str (), 0700 );
133135 fs::create_symlink (executable, bin / " path-appimage" );
136+ fs::create_symlink (executable, bin / " shadowed-native" );
134137 fs::create_symlink (executable, workingDirectory / " native-app" );
135138 }
136139 {
@@ -141,6 +144,10 @@ namespace {
141144 std::ofstream entry (applications / " path.desktop" );
142145 entry << " [Desktop Entry]\n Type=Application\n Name=PATH AppImage\n Exec=path-appimage\n " ;
143146 }
147+ {
148+ std::ofstream entry (systemApplications / " shadowed-native.desktop" );
149+ entry << " [Desktop Entry]\n Type=Application\n Name=Shadowed Native App\n Exec=shadowed-native\n " ;
150+ }
144151
145152 const char * oldDataHome = std::getenv (" XDG_DATA_HOME" );
146153 const char * oldDataDirs = std::getenv (" XDG_DATA_DIRS" );
@@ -153,7 +160,7 @@ namespace {
153160 oldPath == nullptr ? std::nullopt : std::optional<std::string>(oldPath);
154161 const fs::path savedWorkingDirectory = fs::current_path ();
155162 setenv (" XDG_DATA_HOME" , (root / " data" ).c_str (), 1 );
156- setenv (" XDG_DATA_DIRS" , (root / " empty " ).c_str (), 1 );
163+ setenv (" XDG_DATA_DIRS" , (root / " system " ).c_str (), 1 );
157164 setenv (" PATH" , bin.c_str (), 1 );
158165 fs::current_path (workingDirectory);
159166
@@ -167,6 +174,7 @@ namespace {
167174 TEST_CHECK (findOrigin (" suffix" ) == DesktopEntryOrigin::AppImage);
168175 TEST_CHECK (findOrigin (" native" ) == DesktopEntryOrigin::System);
169176 TEST_CHECK (findOrigin (" path" ) == DesktopEntryOrigin::AppImage);
177+ TEST_CHECK (findOrigin (" shadowed-native" ) == DesktopEntryOrigin::System);
170178
171179 fs::current_path (savedWorkingDirectory);
172180
0 commit comments