Skip to content

Commit 422bb08

Browse files
committed
fix: update null command runner to use hex/toml format for exported apps
The build_exported_apps_commands function was using an old format with '# START FILE' markers, but the POSIX_FIND_AND_CONCAT_DESKTOP_FILES.sh script now outputs TOML with hex-encoded paths and contents. This fix: - Adds a to_hex helper function to DistroboxCommandRunnerResponse - Updates build_exported_apps_commands to generate proper TOML format - Uses the box_name parameter correctly for exported file names
1 parent 3d81d6e commit 422bb08

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

src/backends/distrobox/distrobox.rs

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,11 @@ pub enum DistroboxCommandRunnerResponse {
333333
}
334334

335335
impl DistroboxCommandRunnerResponse {
336+
/// Helper to encode a string as hex (matching the shell script's base16 function)
337+
fn to_hex(s: &str) -> String {
338+
s.bytes().map(|b| format!("{:02x}", b)).collect()
339+
}
340+
336341
pub fn common_distros() -> LazyCell<Vec<ContainerInfo>> {
337342
LazyCell::new(|| {
338343
[
@@ -456,31 +461,42 @@ impl DistroboxCommandRunnerResponse {
456461
"/home/me".to_string(),
457462
));
458463

459-
// List desktop files
464+
// List desktop files - these are the exported files in the user's local applications folder
465+
// Format: {box_name}-{filename}
460466
let file_list = apps
461467
.iter()
462-
.map(|(filename, _, _)| format!("ubuntu-{}", filename))
468+
.map(|(filename, _, _)| format!("{box_name}-{}", filename))
463469
.collect::<Vec<_>>()
464470
.join("\n");
465471
commands.push((
466472
Command::new_with_args("ls", ["/home/me/.local/share/applications"]),
467473
file_list,
468474
));
469475

470-
// Get desktop file contents
471-
let mut contents = String::new();
476+
// Build desktop files TOML with hex encoding (matching POSIX_FIND_AND_CONCAT_DESKTOP_FILES.sh output)
477+
let mut toml = format!("home_dir=\"{}\"\n", Self::to_hex("/home/me"));
478+
479+
toml.push_str("[system]\n");
472480
for (filename, name, icon) in apps {
473-
contents.push_str(&format!(
474-
"# START FILE /usr/share/applications/{}\n\
475-
[Desktop Entry]\n\
481+
let path = format!("/usr/share/applications/{}", filename);
482+
let content = format!(
483+
"[Desktop Entry]\n\
476484
Type=Application\n\
477485
Name={}\n\
478486
Exec=/path/to/{}\n\
479487
Icon={}\n\
480-
Categories=Utility;Network;\n\n",
481-
filename, name, name, icon
488+
Categories=Utility;Network;",
489+
name, name, icon
490+
);
491+
toml.push_str(&format!(
492+
"\"{}\"=\"{}\"\n",
493+
Self::to_hex(&path),
494+
Self::to_hex(&content)
482495
));
483496
}
497+
498+
toml.push_str("[user]\n");
499+
484500
commands.push((
485501
Command::new_with_args(
486502
"distrobox",
@@ -493,7 +509,7 @@ impl DistroboxCommandRunnerResponse {
493509
POSIX_FIND_AND_CONCAT_DESKTOP_FILES,
494510
],
495511
),
496-
contents,
512+
toml,
497513
));
498514

499515
commands

0 commit comments

Comments
 (0)