Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
liias committed Sep 19, 2024
1 parent 6f9f285 commit 253e74c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion extra/linux/dist/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ if [[ $* != *--skip-desktop-database* ]]; then
update-desktop-database "$TARGET_DESKTOP_DIR_PATH"

# Sets Browsers as default application for https and http mimetypes
xdg-mime default "software.Browsers.desktop" https http || echo "Could not make Browsers as default web link opener"
xdg-mime default "software.Browsers.desktop" x-scheme-handler/https x-scheme-handler/http || echo "Could not make Browsers as default web link opener"
fi

echo "Browsers has been installed. Enjoy!"
Expand Down
9 changes: 6 additions & 3 deletions src/linux/linux_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,8 @@ pub fn set_default_web_browser() -> bool {
let result = Command::new("xdg-mime")
.arg("default")
.arg(desktop_file_name.as_str())
.arg("https http")
.arg("x-scheme-handler/https")
.arg("x-scheme-handler/http")
.status();

if result.is_err() {
Expand All @@ -455,8 +456,8 @@ pub fn set_default_web_browser() -> bool {
pub fn is_default_web_browser() -> bool {
let desktop_file_name = format!("{}.desktop", XDG_NAME);

let https_default_app = query_default_app("https").unwrap_or("".to_string());
let http_default_app = query_default_app("http").unwrap_or("".to_string());
let https_default_app = query_default_app("x-scheme-handler/https").unwrap_or("".to_string());
let http_default_app = query_default_app("x-scheme-handler/http").unwrap_or("".to_string());

return https_default_app == desktop_file_name && http_default_app == desktop_file_name;
}
Expand All @@ -478,5 +479,7 @@ fn query_default_app(scheme: &str) -> Option<String> {

// extract the raw bytes that we captured and interpret them as a string
let default_app = String::from_utf8(output.stdout).unwrap();

info!("Default for {scheme} is '{default_app}'");
return Some(default_app);
}

0 comments on commit 253e74c

Please sign in to comment.