From b87790ff9f7eaa24a710d77ad1023495f5426161 Mon Sep 17 00:00:00 2001 From: Brad Date: Sun, 13 Jul 2025 19:19:10 +0100 Subject: [PATCH 1/4] fix(deep-link): handler not set as default on linux `xdg-mime default` needs to be given the full mimetype, not just the protocol on its own --- plugins/deep-link/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/deep-link/src/lib.rs b/plugins/deep-link/src/lib.rs index d74864db..b5fd963e 100644 --- a/plugins/deep-link/src/lib.rs +++ b/plugins/deep-link/src/lib.rs @@ -333,7 +333,7 @@ mod imp { .status()?; Command::new("xdg-mime") - .args(["default", &file_name, _protocol.as_ref()]) + .args(["default", &file_name, mime_type.as_str()]) .status()?; Ok(()) From 860175853c69aa9b7344b4459d333f7783f62ff9 Mon Sep 17 00:00:00 2001 From: Brad Date: Sun, 13 Jul 2025 19:29:54 +0100 Subject: [PATCH 2/4] docs: document xdg-mime-fix --- .changes/deep-link-xdg-mime-fix.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/deep-link-xdg-mime-fix.md diff --git a/.changes/deep-link-xdg-mime-fix.md b/.changes/deep-link-xdg-mime-fix.md new file mode 100644 index 00000000..11b01afa --- /dev/null +++ b/.changes/deep-link-xdg-mime-fix.md @@ -0,0 +1,6 @@ +--- +"deep-link": patch +"deep-link-js": patch +--- + +Fix deep link protocol handler not set as default on linux From 218ec686bba6f6ee883d03ba4201130f12a4d560 Mon Sep 17 00:00:00 2001 From: Brad Date: Sun, 13 Jul 2025 20:22:29 +0100 Subject: [PATCH 3/4] fix(deep-link): duplicate MimeType entries added to .desktop just check that it isn't already in there before appending it --- .changes/deep-link-xdg-mime-fix.md | 1 + plugins/deep-link/src/lib.rs | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.changes/deep-link-xdg-mime-fix.md b/.changes/deep-link-xdg-mime-fix.md index 11b01afa..6b25d4ea 100644 --- a/.changes/deep-link-xdg-mime-fix.md +++ b/.changes/deep-link-xdg-mime-fix.md @@ -4,3 +4,4 @@ --- Fix deep link protocol handler not set as default on linux +Fix duplicate protocols added to MimeType section in .desktop files on linux diff --git a/plugins/deep-link/src/lib.rs b/plugins/deep-link/src/lib.rs index b5fd963e..17bf8033 100644 --- a/plugins/deep-link/src/lib.rs +++ b/plugins/deep-link/src/lib.rs @@ -303,12 +303,15 @@ mod imp { if let Ok(mut desktop_file) = ini::Ini::load_from_file(&target_file) { if let Some(section) = desktop_file.section_mut(Some("Desktop Entry")) { - let old_mimes = section.remove("MimeType"); - section.append( - "MimeType", - format!("{mime_type};{}", old_mimes.unwrap_or_default()), - ); - desktop_file.write_to_file(&target_file)?; + // it's ok to remove it - we only write to the file if it's missing + // and in that case we include old_mimes + let old_mimes = section.remove("MimeType").unwrap_or_default(); + + if !old_mimes.split(';').any(|mime| mime == mime_type) { + section.remove("MimeType"); + section.append("MimeType", format!("{mime_type};{}", old_mimes)); + desktop_file.write_to_file(&target_file)?; + } } } else { let mut file = File::create(target_file)?; From 06e26a56a7f032e0dd6f1ba8b5ceb2df7c6540d2 Mon Sep 17 00:00:00 2001 From: Brad Date: Mon, 14 Jul 2025 08:47:35 +0100 Subject: [PATCH 4/4] fix(deep-link): unnecessary second MimeType section removal --- plugins/deep-link/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/deep-link/src/lib.rs b/plugins/deep-link/src/lib.rs index 17bf8033..28679315 100644 --- a/plugins/deep-link/src/lib.rs +++ b/plugins/deep-link/src/lib.rs @@ -308,7 +308,6 @@ mod imp { let old_mimes = section.remove("MimeType").unwrap_or_default(); if !old_mimes.split(';').any(|mime| mime == mime_type) { - section.remove("MimeType"); section.append("MimeType", format!("{mime_type};{}", old_mimes)); desktop_file.write_to_file(&target_file)?; }