Skip to content

Commit

Permalink
fix(packager): Linux Exec when binary contains spaces (#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog-crabnebula authored Jan 13, 2025
1 parent 6e638b5 commit 82e690d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changes/fix-exec-linux.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"cargo-packager": patch
---

Fix the `Exec` entry on the Linux .desktop file when the binary name contains spaces.
8 changes: 7 additions & 1 deletion crates/packager/src/package/deb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ fn generate_desktop_file(config: &Config, data_dir: &Path) -> crate::Result<()>

let mime_type = (!mime_type.is_empty()).then(|| mime_type.join(";"));

let bin_name_exec = if bin_name.contains(' ') {
format!("\"{bin_name}\"")
} else {
bin_name.to_string()
};

handlebars.render_to_write(
"main.desktop",
&DesktopTemplateParams {
Expand All @@ -166,7 +172,7 @@ fn generate_desktop_file(config: &Config, data_dir: &Path) -> crate::Result<()>
.map(|category| category.gnome_desktop_categories())
.unwrap_or(""),
comment: config.description.as_deref(),
exec: &bin_name,
exec: &bin_name_exec,
exec_arg,
icon: &bin_name,
name: config.product_name.as_str(),
Expand Down

0 comments on commit 82e690d

Please sign in to comment.