Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions extension/src/sites/manage.html
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,27 @@
</div>
</div>

<div class="list-group-item d-none" id="settings-use-linked-rt" data-i18n data-i18n-title="commonLoading">
<div class="row align-items-center">
<div class="col">
<label class="fw-bold mb-0" for="settings-use-linked-rt" data-i18n="managePageSettingsEnableLinkedRuntime"></label>
</div>
<div class="col-auto">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="settings-use-linked-rt" disabled>
</div>
</div>
</div>
</div>

<div class="list-group-item d-none">
<div>
<label class="fw-bold mb-0" for="settings-linked-rt-path" data-i18n="managePageSettingsDefaultProfileTemplate"></label>
<input type="text" class="form-control form-control-sm" id="settings-linked-rt-path" data-i18n data-i18n-placeholder="managePageSettingsLinkedRuntimePath" />
<!-- This has to be a text input because Firefox does not support file inputs in extension popups -->
</div>
</div>

<div class="list-group-item">
<div class="row align-items-center" data-i18n data-i18n-title="managePageSettingsDarkModeTooltip">
<div class="col">
Expand Down
10 changes: 10 additions & 0 deletions extension/src/sites/manage.js
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,8 @@ async function handleSettings (hasChanged = false) {
document.getElementById('settings-enable-wayland-container').classList.remove('d-none')
document.getElementById('settings-use-xinput2-container').classList.remove('d-none')
document.getElementById('settings-use-portals-container').classList.remove('d-none')
document.getElementById('settings-use-linked-rt').classList.remove('d-none')
document.getElementById('settings-settings-linked-rt-path').classList.remove('d-none')
}

// Hide patching setting on macOS
Expand All @@ -1063,6 +1065,8 @@ async function handleSettings (hasChanged = false) {
document.getElementById('settings-use-xinput2').checked = config.runtime_use_xinput2
document.getElementById('settings-use-portals').checked = config.runtime_use_portals
document.getElementById('settings-always-patch').checked = config.always_patch
document.getElementById('settings-use-linked-rt').checked = config.use_linked_runtime
document.getElementById('settings-settings-linked-rt-path').checked = config.linked_runtime_path
Comment on lines +1068 to +1069
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runtime instead of rt for element IDs seems nicer.


// Enable settings inputs
document.getElementById('settings-enable-wayland-container').title = ''
Expand Down Expand Up @@ -1098,6 +1102,12 @@ async function handleSettings (hasChanged = false) {
config.always_patch = this.checked
await setConfig(config)
})

// Listen for use linked Runtime
document.getElementById('settings-use-linked-rt').addEventListener('change', async function () {
config.always_patch = this.checked
await setConfig(config)
})
Comment on lines +1106 to +1110
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems handling the runtime path is missing here.

})

// Hide runtime reinstallation button on unsupported platforms
Expand Down
5 changes: 3 additions & 2 deletions native/src/components/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,12 @@ impl Runtime {
self.uninstall()?;

storage.config.use_linked_runtime = true;
storage.config.linked_runtime_path = FFOX.to_string();
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probybly shouldn't override the user-configured path.


info!("Linking the runtime");

if Path::new(FFOX).exists() {
for entry in read_dir(FFOX)?.flatten() {
if Path::new(&storage.config.linked_runtime_path).exists() {
for entry in read_dir(&storage.config.linked_runtime_path)?.flatten() {
let entry = entry.path();
match entry.file_name().expect("Couldn't retrieve a file name").to_str() {
// Use a different branch for the "defaults" folder due to the patches to apply afterwhile
Expand Down
2 changes: 2 additions & 0 deletions native/src/connector/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ impl Process for InstallRuntime {
let command = RuntimeInstallCommand {
#[cfg(platform_linux)]
link: options.link,
#[cfg(platform_linux)]
path: options.path,
};
command.run()?;

Expand Down
3 changes: 3 additions & 0 deletions native/src/connector/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ pub struct InstallRuntimeOptions {
/// Whether to use a linked runtime instead of downloading from Mozilla (experimental, default: `false`).
#[serde(default)]
pub link: bool,
/// Experimental: Use a linked runtime instead of downloading from Mozilla.
/// Optional: Path of my firefox runtime
pub path: String,
}

pub type InstallRuntime = Option<InstallRuntimeOptions>;
Expand Down
9 changes: 8 additions & 1 deletion native/src/console/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use clap::{ArgAction, Parser};
use ulid::Ulid;
use url::Url;

const FFOX: &str = "/usr/lib/firefox/";

#[derive(Parser, Debug, Eq, PartialEq, Clone)]
#[clap(propagate_version = true)]
#[clap(version)]
Expand Down Expand Up @@ -278,8 +280,13 @@ pub enum RuntimeCommand {
pub struct RuntimeInstallCommand {
/// Experimental: Use a linked runtime instead of downloading from Mozilla
#[cfg(target_os = "linux")]
#[clap(long)]
#[clap(long, short)]
pub link: bool,
/// Experimental: Use a linked runtime instead of downloading from Mozilla.
/// Optional: Path of my firefox runtime
#[cfg(target_os = "linux")]
#[clap(long, value_name = FFOX)]
pub path: String,
Comment on lines 281 to +289
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be better if this is a single option/parameter that can optionally take a path. So, when firefoxpwa runtime install --link is ran, the default path is used (depending on the operating system, distribution, etc.), and when the user explicitly specifies firefoxpwa runtime install --link=SOME-PATH, that path is used instead.

This should probably also be reflected in the storage/config. So that the path is only stored when its explicitly set.

}

#[derive(Parser, Debug, Eq, PartialEq, Clone)]
Expand Down
5 changes: 5 additions & 0 deletions native/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ pub struct Config {
/// Experimental: Using the system runtime to save some disk space.
/// This might not work on your system.
pub use_linked_runtime: bool,

#[cfg(platform_linux)]
/// Experimental: Using the system runtime to save some disk space.
/// Change the path of Firefox in linked runtime mode.
pub linked_runtime_path: String,
}

#[non_exhaustive]
Expand Down