Skip to content

Commit 2322ac1

Browse files
authored
fix(bundler): bundle /usr/bin/xdg-open in appimage if open API enabled (#4265)
1 parent b369069 commit 2322ac1

6 files changed

Lines changed: 31 additions & 5 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"cli.rs": patch
3+
"cli.js": patch
4+
---
5+
6+
Configure the AppImage bundler to copy the `/usr/bin/xdg-open` binary if it exists and the shell `open` API is enabled.

.changes/fix-appimage-shell-api.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-bundler": patch
3+
---
4+
5+
Copy the `/usr/bin/xdg-open` binary if it exists and the `APPIMAGE_BUNDLE_XDG_OPEN` environment variable is set.

examples/api/dist/assets/vendor.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/api/src-tauri/tauri.conf.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
}
9393
},
9494
"shell": {
95+
"open": true,
9596
"scope": [
9697
{
9798
"name": "sh",

tooling/bundler/src/bundle/linux/templates/appimage

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@
66
set -euxo pipefail
77

88
export ARCH={{arch}}
9+
APPIMAGE_BUNDLE_XDG_OPEN=${APPIMAGE_BUNDLE_XDG_OPEN-0}
910

1011
mkdir -p "{{app_name}}.AppDir"
1112
cp -r ../appimage_deb/data/usr "{{app_name}}.AppDir"
1213

1314
cd "{{app_name}}.AppDir"
1415

16+
if [[ "$APPIMAGE_BUNDLE_XDG_OPEN" != "0" ]] && [[ -f "/usr/bin/xdg-open" ]]; then
17+
echo "Copying /usr/bin/xdg-open"
18+
cp /usr/bin/xdg-open usr/bin
19+
fi
20+
1521
# Copy WebKit files.
1622
find /usr/lib* -name WebKitNetworkProcess -exec mkdir -p "$(dirname '{}')" \; -exec cp --parents '{}' "." \; || true
1723
find /usr/lib* -name WebKitWebProcess -exec mkdir -p "$(dirname '{}')" \; -exec cp --parents '{}' "." \; || true

tooling/cli/src/build.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use crate::helpers::{
66
app_paths::{app_dir, tauri_dir},
77
command_env,
8-
config::{get as get_config, AppUrl, WindowUrl},
8+
config::{get as get_config, AppUrl, ShellAllowlistOpen, WindowUrl},
99
manifest::rewrite_manifest,
1010
updater_signature::sign_file_from_env_variables,
1111
};
@@ -302,6 +302,14 @@ pub fn command(options: Options) -> Result<()> {
302302
)
303303
.with_context(|| "failed to build bundler settings")?;
304304

305+
// set env vars used by the bundler
306+
if matches!(
307+
config_.tauri.allowlist.shell.open,
308+
ShellAllowlistOpen::Flag(true) | ShellAllowlistOpen::Validate(_)
309+
) {
310+
std::env::set_var("APPIMAGE_BUNDLE_XDG_OPEN", "1");
311+
}
312+
305313
let bundles = bundle_project(settings).with_context(|| "failed to bundle project")?;
306314

307315
// If updater is active

0 commit comments

Comments
 (0)