Skip to content

Visual Studio Code, rebuilt in Rust

Rust

feat(linux): close desktop platform gaps over D-Bus and Secret Service (#5)

Artur Rok9af857621aa7
diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
index b44d81c50f1..9758dc55a61 100644
--- a/.github/workflows/linux.yml
+++ b/.github/workflows/linux.yml
@@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-24.04
timeout-minutes: 120
steps:
- - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: System packages
# port/tools/linux/Dockerfile's list, with libkrb5-dev and libxkbfile-dev for VS Code's native modules.
run: |
@@ -28,7 +28,7 @@ jobs:
sudo apt-get install -y --no-install-recommends pkg-config clang \
libasound2-dev libfontconfig-dev libfreetype-dev libwayland-dev libx11-xcb-dev libxcb1-dev libxkbcommon-x11-dev \
libssl-dev libzstd-dev libdbus-1-dev libwebkit2gtk-4.1-dev libsecret-1-dev libkrb5-dev libxkbfile-dev file
- - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
+ - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
@@ -53,7 +53,7 @@ jobs:
- run: port/tools/package-linux
env:
PRERELEASE: ${{ inputs.prerelease && '1' || '' }}
- - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
+ - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: linux-x64
path: |
diff --git a/native/Cargo.lock b/native/Cargo.lock
index 9c1147f0bbc..45a815efe21 100644
--- a/native/Cargo.lock
+++ b/native/Cargo.lock
@@ -265,6 +265,7 @@ dependencies = [
"ttf-parser",
"url",
"wuff",
+ "zbus 5.19.0",
]
[[package]]
@@ -1711,15 +1712,18 @@ name = "exthost"
version = "0.1.0"
dependencies = [
"anyhow",
+ "async-lock",
"base64",
"block2 0.6.2",
"config",
"ed25519-dalek",
"files",
"flate2",
+ "futures",
"md-5",
"objc2 0.6.5",
"objc2-foundation 0.3.2",
+ "oo7",
"search",
"security-framework",
"semver",
diff --git a/native/crates/app/Cargo.toml b/native/crates/app/Cargo.toml
index 9af2060c80e..e7a5f8df76e 100644
--- a/native/crates/app/Cargo.toml
+++ b/native/crates/app/Cargo.toml
@@ -50,6 +50,10 @@ objc2-foundation = { version = "0.3.2", default-features = false, features = ["N
objc2-web-kit = { version = "0.3.2", default-features = false, features = ["WKNavigation", "WKPreferences", "WKScriptMessage", "WKScriptMessageHandler", "WKURLSchemeHandler", "WKURLSchemeTask", "WKUserContentController", "WKUserScript", "WKWebView", "WKWebViewConfiguration", "block2", "objc2-app-kit", "objc2-core-foundation"] }
security-framework = "3"
+[target.'cfg(target_os = "linux")'.dependencies]
+# The zbus gpui_linux's ashpd and oo7 use.
+zbus = { version = "5", default-features = false, features = ["async-io", "blocking-api"] }
+
[build-dependencies]
regex = "1"
serde_json.workspace = true
diff --git a/native/crates/app/src/accessibility_signals.rs b/native/crates/app/src/accessibility_signals.rs
index 8b38956a063..6f2260326da 100644
--- a/native/crates/app/src/accessibility_signals.rs
+++ b/native/crates/app/src/accessibility_signals.rs
@@ -1,7 +1,7 @@
//! platform/accessibilitySignal: the signals of accessibilitySignalService.ts with their sounds and settings,
-//! `checkEnabledState`, the volume, and playback of the upstream mp3 files through NSSound.
+//! `checkEnabledState`, the volume, and playback of the upstream mp3 files through NSSound, on Linux through
+//! PipeWire's or PulseAudio's player.
-#[cfg(target_os = "macos")]
use std::collections::HashMap;
use std::path::{Path, PathBuf};
@@ -104,6 +104,8 @@ pub struct SoundPlayer {
media: PathBuf,
#[cfg(target_os = "macos")]
sounds: HashMap<&'static str, Retained<NSSound>>,
+ #[cfg(target_os = "linux")]
+ players: HashMap<&'static str, std::process::Child>,
}
impl SoundPlayer {
@@ -112,12 +114,29 @@ impl SoundPlayer {
media: app_root.join("src/vs/platform/accessibilitySignal/browser/media"),
#[cfg(target_os = "macos")]
sounds: HashMap::new(),
+ #[cfg(target_os = "linux")]
+ players: HashMap::new(),
}
}
#[cfg(target_os = "linux")]
- pub fn play(&mut self, file_name: &'static str, _volume_percent: f64) {
- eprintln!("Error while playing sound: no audio output on Linux yet ({})", self.media.join(file_name).display());
+ pub fn play(&mut self, file_name: &'static str, volume_percent: f64) {
+ use std::process::Command;
+ // A replayed sound starts over, as the macOS player's stop and rewind; the kill and wait also reap a player that ended.
+ if let Some(mut previous) = self.players.remove(file_name) {
+ let _ = previous.kill();
+ let _ = previous.wait();
+ }
+ let path = self.media.join(file_name);
+ let volume = volume_percent / 100.;
+ // Both decode mp3 through libsndfile 1.1 or later; paplay's volume is linear up to 65536.
+ let player = Command::new("pw-play").arg(format!("--volume={volume}")).arg(&path).spawn().or_else(|_| Command::new("paplay").arg(format!("--volume={}", (volume * 65536.) as u32)).arg(&path).spawn());
+ match player {
+ Ok(player) => {
+ self.players.insert(file_name, player);
+ }
+ Err(error) => eprintln!("Error while playing sound: {error} ({})", path.display()),
+ }
}
#[cfg(target_os = "macos")]
diff --git a/native/crates/app/src/diagnostics.rs b/native/crates/app/src/diagnostics.rs
index 6023399f245..812e238ab45 100644
--- a/native/crates/app/src/diagnostics.rs
+++ b/native/crates/app/src/diagnostics.rs
@@ -305,14 +305,12 @@ fn format_workspace_stats(stats: &WorkspaceStats) -> String {
}
/// The running machine, as Node's `os` reports it on macOS.
+#[cfg(target_os = "macos")]
pub fn machine() -> Machine {
let sysctl = |key: &str| std::process::Command::new("/usr/sbin/sysctl").args(["-n", key]).output().map(|output| String::from_utf8_lossy(&output.stdout).trim().to_owned()).unwrap_or_default();
- let mut load_average = [0f64; 3];
- // SAFETY: getloadavg writes at most the 3 elements it is given.
- unsafe { libc::getloadavg(load_average.as_mut_ptr(), 3) };
Machine {
os_type: "Darwin".into(),
- arch: std::env::consts::ARCH.replace("aarch64", "arm64").replace("x86_64", "x64"),
+ arch: node_arch(),
release: sysctl("kern.osrelease"),
cpu_model: sysctl("machdep.cpu.brand_string"),
cpu_count: sysctl("hw.ncpu").parse().unwrap_or_default(),
@@ -320,11 +318,55 @@ pub fn machine() -> Machine {
cpu_speed: sysctl("hw.cpufrequency").parse::<u64>().map_or(2400, |hz| hz / 1_000_000),
total_memory: sysctl("hw.memsize").parse().unwrap_or_default(),
free_memory: crate::workbench::perf_view::free_memory(),
- load_average,
+ load_average: load_average(),
+ vm_hint: virtual_machine_hint(),
+ }
+}
+
+/// The running machine, as Node's `os` reports it on Linux: libuv linux.c reads `/proc/cpuinfo`, `/proc/meminfo`
+/// (`MemAvailable` is the free memory) and cpufreq's `scaling_cur_freq`.
+#[cfg(target_os = "linux")]
+pub fn machine() -> Machine {
+ let read = |path: &str| std::fs::read_to_string(path).unwrap_or_default();
+ let cpuinfo = read("/proc/cpuinfo");
+ let meminfo = read("/proc/meminfo");
+ Machine {
+ os_type: "Linux".into(),
+ arch: node_arch(),
+ release: read("/proc/sys/kernel/osrelease").trim().to_owned(),
+ cpu_model: proc_field(&cpuinfo, "model name").unwrap_or("unknown").to_owned(),
+ cpu_count: cpuinfo.lines().filter(|line| line.split(':').next().is_some_and(|key| key.trim() == "processor")).count(),
+ cpu_speed: read("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq").trim().parse::<u64>().map_or(0, |khz| khz / 1000),
+ total_memory: proc_kilobytes(&meminfo, "MemTotal"),
+ free_memory: proc_kilobytes(&meminfo, "MemAvailable"),
+ load_average: load_average(),
vm_hint: virtual_machine_hint(),
}
}
+/// The value of the first `key: value` line of a `/proc` file.
+#[cfg(any(target_os = "linux", test))]
+fn proc_field<'a>(text: &'a str, key: &str) -> Option<&'a str> {
+ text.lines().find_map(|line| line.split_once(':').filter(|(name, _)| name.trim() == key).map(|(_, value)| value.trim()))
+}
+
+/// A `/proc/meminfo` entry (`MemTotal: 16314764 kB`) in bytes.
+#[cfg(any(target_os = "linux", test))]
+fn proc_kilobytes(meminfo: &str, key: &str) -> f64 {
+ proc_field(meminfo, key).and_then(|value| value.trim_end_matches("kB").trim().parse::<f64>().ok()).map_or(0., |kilobytes| kilobytes * 1024.)
+}
+
+fn node_arch() -> String {
+ std::env::consts::ARCH.replace("aarch64", "arm64").replace("x86_64", "x64")
+}
+
+fn load_average() -> [f64; 3] {
+ let mut load_average = [0f64; 3];
+ // SAFETY: getloadavg writes at most the 3 elements it is given.
+ unsafe { libc::getloadavg(load_average.as_mut_ptr(), 3) };
+ load_average
+}
+
/// base/node/id.ts `virtualMachineHint`: the share of external interface addresses whose MAC has a VM vendor prefix.
fn virtual_machine_hint() -> f64 {
const VM_OUIS: [&str; 7] = ["00:50:56", "00:0C:29", "00:05:69", "00:03:FF", "00:1C:42", "00:16:3E", "08:00:27"];
diff --git a/native/crates/app/src/diagnostics/tests.rs b/native/crates/app/src/diagnostics/tests.rs
index b0b5ce5e8bf..7291c0f70e0 100644
--- a/native/crates/app/src/diagnostics/tests.rs
+++ b/native/crates/app/src/diagnostics/tests.rs
@@ -16,12 +16,28 @@ fn write(root: &Path, relative: &str, text: &str) {
}
/// Node's `os.cpus()[0].speed` on Apple silicon, measured on an M1 Max: 2400.
-#[cfg(target_arch = "aarch64")]
+#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
#[test]
fn apple_silicon_reports_libuvs_fallback_cpu_speed() {
assert_eq!(machine().cpu_speed, 2400);
}
+#[test]
+fn proc_files_give_the_cpu_model_and_memory_in_bytes() {
+ let cpuinfo = "processor\t: 0\nmodel name\t: Intel(R) Xeon(R) CPU\nflags\t\t: fpu vme\n";
+ assert_eq!(proc_field(cpuinfo, "model name"), Some("Intel(R) Xeon(R) CPU"));
+ assert_eq!(proc_kilobytes("MemTotal: 16314764 kB\nMemAvailable: 2048 kB\n", "MemAvailable"), 2048. * 1024.);
+}
+
+#[cfg(target_os = "linux")]
+#[test]
+fn linux_machine_reads_proc() {
+ let machine = machine();
+ assert_eq!(machine.os_type, "Linux");
+ assert!(machine.cpu_count > 0 && machine.total_memory > machine.free_memory && machine.free_memory > 0.);
+ assert!(!machine.release.is_empty());
+}
+
#[test]
fn workspace_stats_count_types_and_config_files_outside_node_modules_and_git() {
let root = temp_folder("stats");
diff --git a/native/crates/app/src/file_dialog.rs b/native/crates/app/src/file_dialog.rs
index 2f757d83c99..3b4e6b864b4 100644
--- a/native/crates/app/src/file_dialog.rs
+++ b/native/crates/app/src/file_dialog.rs
@@ -30,7 +30,9 @@ pub fn show_open_dialog(dialog: FileDialog, cx: &App) -> oneshot::Receiver<Vec<P
if !cfg!(test) {
return macos::show_open_dialog(dialog, cx);
}
- let picked = cx.prompt_for_paths(PathPromptOptions { files: dialog.files, directories: dialog.folders, multiple: dialog.multiple, prompt: None });
+ // labels.ts `mnemonicButtonLabel` on Linux: `&&` marks the mnemonic as GTK's `_`.
+ let prompt = dialog.button_label.map(|label| label.replace("&&", "_").into());
+ let picked = cx.prompt_for_paths(PathPromptOptions { files: dialog.files, directories: dialog.folders, multiple: dialog.multiple, prompt });
gpui_prompt(picked, cx, |picked| picked.unwrap_or_default())
}
diff --git a/native/crates/app/src/main.rs b/native/crates/app/src/main.rs
index b64f1fa80df..56e8c9dabb3 100644
--- a/native/crates/app/src/main.rs
+++ b/native/crates/app/src/main.rs
@@ -485,7 +485,7 @@ pub(crate) fn open_window(request: WindowRequest, cx: &mut App) -> anyhow::Resul
let window_extensions = WindowExtensions { builtins: builtins.clone(), user: user_extensions.clone_for_profile(), running: extensions.clone(), proposed_api: proposed_api.clone() };
let theme = match flag_value("--theme") {
Some(theme_id) => load_theme(&extensions, &theme_id)?,
- None => settings_theme(&extensions, &settings)?,
+ None => settings_theme(&extensions, &settings, cx)?,
};
let file_icons = settings_file_icons(&extensions, &settings)?;
let color_themes = theme::color_themes(&extensions)?;
@@ -855,8 +855,8 @@ fn save_screenshot(_window: &Window, _path: &std::path::Path) -> anyhow::Result<
}
/// The color theme setting for the host scheme (`getColorThemeSettingId`); a theme no extension contributes falls back to the default, as ThemeService does.
-fn settings_theme(extensions: &[ScannedExtension], settings: &Settings) -> anyhow::Result<theme::Theme> {
- let key = workbench::themes::color_theme_setting_id(settings, workbench::themes::host_color_scheme());
+fn settings_theme(extensions: &[ScannedExtension], settings: &Settings, cx: &App) -> anyhow::Result<theme::Theme> {
+ let key = workbench::themes::color_theme_setting_id(settings, workbench::themes::host_color_scheme(cx));
let id = settings.get_value(Some(key), &Overrides::default());
if let Some(theme) = id.as_ref().and_then(|id| id.as_str()).and_then(|id| load_theme(extensions, id).ok()) {
return Ok(theme);
diff --git a/native/crates/app/src/metered_connection.rs b/native/crates/app/src/metered_connection.rs
index f98a1474ccf..d11cee68118 100644
--- a/native/crates/app/src/metered_connection.rs
+++ b/native/crates/app/src/metered_connection.rs
@@ -1,4 +1,4 @@
-//! platform/meteredConnection on macOS: whether the OS reports the network path as metered, the native side of
+//! platform/meteredConnection on macOS and Linux: whether the OS reports the network path as metered, the native side of
//! meteredConnection.ts `getIsBrowserConnectionMetered`, and the `network.meteredConnection` setting over it.
#[cfg(target_os = "macos")]
@@ -52,9 +52,25 @@ pub fn watch(updates: UnboundedSender<bool>) {
}
}
-/// Chromium's `navigator.connection` on Linux reports no metered state either; the setting alone decides.
+/// Chromium's `navigator.connection` on Linux reports no metered state either; as on macOS the OS decides:
+/// NetworkManager's `Metered` (NMMetered) is `YES` or `GUESS_YES`. Sent first, then on every change.
#[cfg(target_os = "linux")]
-pub fn watch(_updates: UnboundedSender<bool>) {}
+pub fn watch(updates: UnboundedSender<bool>) {
+ std::thread::spawn(move || {
+ let manager = zbus::blocking::Connection::system().and_then(|system| zbus::blocking::Proxy::new(&system, "org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager", "org.freedesktop.NetworkManager"));
+ let Ok(manager) = manager else { return };
+ let is_metered = |metered: u32| matches!(metered, 1 | 3);
+ if let Ok(metered) = manager.get_property::<u32>("Metered") {
+ drop(updates.unbounded_send(is_metered(metered)));
+ }
+ for change in manager.receive_property_changed::<u32>("Metered") {
+ let Ok(metered) = change.get() else { continue };
+ if updates.unbounded_send(is_metered(metered)).is_err() {
+ return;
+ }
+ }
+ });
+}
/// `AbstractMeteredConnectionService`: `on` always, `off` never, `auto` (or any other value) the OS state.
pub fn is_metered(setting: Option<&str>, os_metered: bool) -> bool {
diff --git a/native/crates/app/src/power.rs b/native/crates/app/src/power.rs
index b82f7dfb60e..85b813a301a 100644
--- a/native/crates/app/src/power.rs
+++ b/native/crates/app/src/power.rs
@@ -11,11 +11,11 @@ mod linux;
#[cfg(target_os = "macos")]
mod macos;
#[cfg(target_os = "linux")]
-use linux::{create_assertion, release_assertion, screen_locked};
+use linux::{Assertion, create_assertion, release_assertion, screen_locked};
#[cfg(target_os = "linux")]
-pub use linux::{on_battery_power, system_idle_time, thermal_state, watch, watch_accessibility_display};
+pub use linux::{animations_disabled, on_battery_power, system_idle_time, thermal_state, watch, watch_accessibility_display};
#[cfg(target_os = "macos")]
-use macos::{create_assertion, release_assertion, screen_locked};
+use macos::{Assertion, create_assertion, release_assertion, screen_locked};
#[cfg(target_os = "macos")]
pub use macos::{on_battery_power, system_idle_time, thermal_state, watch, watch_accessibility_display};
@@ -42,7 +42,7 @@ fn thermal_state_name(state: isize) -> &'static str {
#[derive(Default)]
pub struct PowerSaveBlockers {
next_id: i64,
- assertions: HashMap<i64, u32>,
+ assertions: HashMap<i64, Assertion>,
}
impl PowerSaveBlockers {
diff --git a/native/crates/app/src/power/linux.rs b/native/crates/app/src/power/linux.rs
index 57cf2f0ba51..4be95603d53 100644
--- a/native/crates/app/src/power/linux.rs
+++ b/native/crates/app/src/power/linux.rs
@@ -1,33 +1,139 @@
-//! IPowerService on Linux, not wired to the desktop yet: no idle time, lock or battery state, no sleep inhibitors and
-//! no power events. Electron reads these from XScreenSaver, logind and UPower.
+//! IPowerService on Linux over D-Bus, as Chromium: idle time from Mutter's IdleMonitor or the ScreenSaver service,
+//! lock state and sleep events from logind, the power source from UPower, blockers as ScreenSaver and logind
+//! inhibitors. Electron has no thermal state and only the suspend, resume and shutdown events on Linux.
+
+use std::sync::atomic::{AtomicBool, Ordering};
+use std::sync::{LazyLock, Mutex, Once};
use futures::channel::mpsc::UnboundedSender;
+use zbus::blocking::{Connection, Proxy};
+use zbus::zvariant::{OwnedFd, OwnedValue};
use super::PowerEvent;
+static SYSTEM: LazyLock<Option<Connection>> = LazyLock::new(|| Connection::system().ok());
+static SESSION: LazyLock<Option<Connection>> = LazyLock::new(|| Connection::session().ok());
+
+const LOGIND: &str = "org.freedesktop.login1";
+const APP_NAME: &str = "Electron";
+
+fn proxy(bus: &'static Option<Connection>, destination: &'static str, path: &'static str, interface: &'static str) -> Option<Proxy<'static>> {
+ Proxy::new(bus.as_ref()?, destination, path, interface).ok()
+}
+
+fn screen_saver() -> Option<Proxy<'static>> {
+ proxy(&SESSION, "org.freedesktop.ScreenSaver", "/org/freedesktop/ScreenSaver", "org.freedesktop.ScreenSaver")
+}
+
+fn logind() -> Option<Proxy<'static>> {
+ proxy(&SYSTEM, LOGIND, "/org/freedesktop/login1", "org.freedesktop.login1.Manager")
+}
+
+/// powerMonitor.getSystemIdleTime: whole seconds since the last input event, 0 without an idle monitor on the bus.
pub fn system_idle_time() -> u64 {
- 0
+ let mutter = proxy(&SESSION, "org.gnome.Mutter.IdleMonitor", "/org/gnome/Mutter/IdleMonitor/Core", "org.gnome.Mutter.IdleMonitor");
+ if let Some(milliseconds) = mutter.and_then(|mutter| mutter.call::<_, _, u64>("GetIdletime", &()).ok()) {
+ return milliseconds / 1000;
+ }
+ screen_saver().and_then(|screen_saver| screen_saver.call::<_, _, u32>("GetSessionIdleTime", &()).ok()).map_or(0, u64::from)
}
pub(super) fn screen_locked() -> bool {
- false
+ let session = proxy(&SYSTEM, LOGIND, "/org/freedesktop/login1/session/auto", "org.freedesktop.login1.Session");
+ session.and_then(|session| session.get_property::<bool>("LockedHint").ok()).unwrap_or(false)
}
pub fn thermal_state() -> &'static str {
"unknown"
}
+/// powerMonitor.isOnBatteryPower: UPower's `OnBattery`.
pub fn on_battery_power() -> bool {
- false
+ let upower = proxy(&SYSTEM, "org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.UPower");
+ upower.and_then(|upower| upower.get_property::<bool>("OnBattery").ok()).unwrap_or(false)
+}
+
+/// A ScreenSaver inhibit cookie for `prevent-display-sleep`, a logind `sleep` inhibitor fd for the rest; `None` when
+/// the bus refuses, while the blocker id still counts as started, as Electron's map of ids does.
+pub(super) type Assertion = Option<Inhibitor>;
+
+pub(super) enum Inhibitor {
+ ScreenSaver(u32),
+ // Logind releases the inhibitor when the fd closes.
+ Logind(#[allow(dead_code)] OwnedFd),
+}
+
+pub(super) fn create_assertion(blocker_type: &str) -> Option<Assertion> {
+ let reason = "Power save blocker";
+ let inhibitor = match blocker_type {
+ "prevent-display-sleep" => screen_saver().and_then(|screen_saver| screen_saver.call("Inhibit", &(APP_NAME, reason)).ok()).map(Inhibitor::ScreenSaver),
+ _ => logind().and_then(|logind| logind.call("Inhibit", &("sleep", APP_NAME, reason, "block")).ok()).map(Inhibitor::Logind),
+ };
+ Some(inhibitor)
}
-/// A blocker that is reported started but inhibits nothing.
-pub(super) fn create_assertion(_blocker_type: &str) -> Option<u32> {
- Some(0)
+pub(super) fn release_assertion(assertion: Assertion) {
+ if let Some(Inhibitor::ScreenSaver(cookie)) = assertion
+ && let Some(screen_saver) = screen_saver()
+ {
+ drop(screen_saver.call::<_, _, ()>("UnInhibit", &(cookie,)));
+ }
}
-pub(super) fn release_assertion(_assertion: u32) {}
+static EVENTS: Mutex<Vec<UnboundedSender<PowerEvent>>> = Mutex::new(Vec::new());
+static OBSERVING: Once = Once::new();
-pub fn watch(_events: UnboundedSender<PowerEvent>) {}
+/// powerMonitor's Linux events as ExtHostPower methods: logind's `PrepareForSleep` as suspend and resume,
+/// `PrepareForShutdown` as shutdown. The watching thread lives as long as the app.
+pub fn watch(events: UnboundedSender<PowerEvent>) {
+ EVENTS.lock().unwrap().push(events);
+ OBSERVING.call_once(|| {
+ std::thread::spawn(observe_power_events);
+ });
+}
+
+fn observe_power_events() {
+ let Some(signals) = logind().and_then(|logind| logind.receive_all_signals().ok()) else { return };
+ for message in signals {
+ let header = message.header();
+ let starting = message.body().deserialize::<bool>().unwrap_or(false);
+ let event = match (header.member().map(|member| member.as_str()), starting) {
+ (Some("PrepareForSleep"), true) => "$onDidSuspend",
+ (Some("PrepareForSleep"), false) => "$onDidResume",
+ (Some("PrepareForShutdown"), true) => "$onWillShutdown",
+ _ => continue,
+ };
+ EVENTS.lock().unwrap().retain(|events| events.unbounded_send((event, Vec::new())).is_ok());
+ }
+}
+
+/// Chromium's `prefers-reduced-motion` on Linux: GTK's `gtk-enable-animations` off, which the desktop portal's
+/// `org.gnome.desktop.interface enable-animations` setting carries. Kept up to date by `watch_accessibility_display`.
+static ANIMATIONS_DISABLED: AtomicBool = AtomicBool::new(false);
+
+pub fn animations_disabled() -> bool {
+ ANIMATIONS_DISABLED.load(Ordering::Relaxed)
+}
+
+/// Electron's `nativeTheme` `updated` for `prefersReducedMotion`: the portal's `enable-animations` changed. Call once.
+pub fn watch_accessibility_display(changed: UnboundedSender<()>) {
+ std::thread::spawn(move || {
+ let Some(settings) = proxy(&SESSION, "org.freedesktop.portal.Desktop", "/org/freedesktop/portal/desktop", "org.freedesktop.portal.Settings") else { return };
+ let enabled = settings.call::<_, _, OwnedValue>("ReadOne", &(INTERFACE_SETTINGS, ENABLE_ANIMATIONS)).ok().and_then(|value| bool::try_from(value).ok());
+ ANIMATIONS_DISABLED.store(enabled == Some(false), Ordering::Relaxed);
+ let Ok(changes) = settings.receive_signal("SettingChanged") else { return };
+ for message in changes {
+ let Ok((namespace, key, value)) = message.body().deserialize::<(String, String, OwnedValue)>() else { continue };
+ if namespace != INTERFACE_SETTINGS || key != ENABLE_ANIMATIONS {
+ continue;
+ }
+ ANIMATIONS_DISABLED.store(bool::try_from(value).ok() == Some(false), Ordering::Relaxed);
+ if changed.unbounded_send(()).is_err() {
+ return;
+ }
+ }
+ });
+}
-pub fn watch_accessibility_display(_changed: UnboundedSender<()>) {}
+const INTERFACE_SETTINGS: &str = "org.gnome.desktop.interface";
+const ENABLE_ANIMATIONS: &str = "enable-animations";
diff --git a/native/crates/app/src/power/macos.rs b/native/crates/app/src/power/macos.rs
index 0478b6874ea..b2e4e21e25e 100644
--- a/native/crates/app/src/power/macos.rs
+++ b/native/crates/app/src/power/macos.rs
@@ -93,8 +93,10 @@ fn speed_limit() -> i64 {
status.find(CFString::new("CPU_Speed_Limit")).and_then(|value| value.downcast::<CFNumber>()).and_then(|number| number.to_i64()).unwrap_or(100)
}
+pub(super) type Assertion = u32;
+
/// An IOPM assertion for a powerSaveBlocker type; `None` when IOKit refuses it.
-pub(super) fn create_assertion(blocker_type: &str) -> Option<u32> {
+pub(super) fn create_assertion(blocker_type: &str) -> Option<Assertion> {
let assertion_type = match blocker_type {
"prevent-display-sleep" => "NoDisplaySleepAssertion",
_ => "NoIdleSleepAssertion",
diff --git a/native/crates/app/src/update.rs b/native/crates/app/src/update.rs
index b429599aaf9..202bf3f53f9 100644
--- a/native/crates/app/src/update.rs
+++ b/native/crates/app/src/update.rs
@@ -1,6 +1,7 @@
//! platform/update (update.ts, abstractUpdateService.ts, updateService.darwin.ts) for the port's macOS app: the feed
//! at product.json `updateUrl` names the newest build, which is downloaded in the background, verified and installed
-//! by a helper after the app quits. The feed format is in port/notes.md ("Update feed").
+//! by a helper after the app quits. On Linux (updateService.linux.ts) a found build waits in AvailableForDownload and
+//! Download opens its link in the browser. The feed format is in port/notes.md ("Update feed").
pub mod install;
pub mod unattended_restart;
@@ -363,6 +364,10 @@ impl UpdateService {
/// The connection turned metered during an automatic check: `deferAutomaticDownload`, as the darwin flow's
/// check without download (`checkForUpdateNoDownload`).
fn found_update(&mut self, update: Update, explicit: bool, cx: &mut Context<Self>) {
+ if cfg!(target_os = "linux") {
+ self.set_state(State::AvailableForDownload { update }, cx);
+ return;
+ }
if explicit || !self.metered {
self.download(update, explicit, cx);
return;
@@ -381,6 +386,13 @@ impl UpdateService {
self.deferred = true;
return;
}
+ if cfg!(target_os = "linux") {
+ // updateService.linux.ts: the package type is unknown, so product.json `downloadUrl` beats the archive.
+ let download_url = crate::product::get("downloadUrl").as_str().filter(|url| !url.is_empty()).unwrap_or(&update.url).to_owned();
+ cx.open_url(&download_url);
+ self.set_state(State::Idle { error: None, not_available: false }, cx);
+ return;
+ }
let update = update.clone();
self.download(update, explicit, cx);
}
@@ -460,9 +472,11 @@ impl UpdateService {
}
}
-/// Squirrel's read-only check, then the feed.
+/// Squirrel's read-only check (macOS), then the feed.
fn find_update(config: &Config, channel: &str) -> anyhow::Result<Option<Update>> {
- install::check_writable(&config.bundle)?;
+ if cfg!(target_os = "macos") {
+ install::check_writable(&config.bundle)?;
+ }
let url = feed_url(&config.update_url, exthost::gallery::CURRENT_TARGET_PLATFORM, channel);
let (status, body) = fetch_feed(&url)?;
if status != 200 {
diff --git a/native/crates/app/src/update/install.rs b/native/crates/app/src/update/install.rs
index 1325b7350ce..98539f917f8 100644
--- a/native/crates/app/src/update/install.rs
+++ b/native/crates/app/src/update/install.rs
@@ -10,12 +10,20 @@ use sha2::{Digest, Sha256};
/// The app bundle the running executable sits in (`<bundle>.app/Contents/MacOS/<executable>`); none when it runs
/// out of a build folder.
+#[cfg(target_os = "macos")]
pub fn running_bundle() -> Option<PathBuf> {
let executable = std::env::current_exe().ok()?;
let bundle = executable.parent()?.parent()?.parent()?;
(bundle.extension()? == "app" && executable.parent()?.ends_with("Contents/MacOS")).then(|| bundle.to_path_buf())
}
+/// The Linux archive's folder (port/tools/package-linux): the executable beside `resources/app`.
+#[cfg(target_os = "linux")]
+pub fn running_bundle() -> Option<PathBuf> {
+ let folder = std::env::current_exe().ok()?.parent()?.to_path_buf();
+ folder.join("resources/app").is_dir().then_some(folder)
+}
+
/// Squirrel.Mac's `<bundle id>.ShipIt` cache folder: the download (`update`, removed at startup) and the helper's log.
pub fn shipit_dir() -> PathBuf {
let id = crate::product::get("darwinBundleIdentifier").as_str().expect("product.json has darwinBundleIdentifier");
diff --git a/native/crates/app/src/update/tests.rs b/native/crates/app/src/update/tests.rs
index ff60f2f7739..1235f08ee86 100644
--- a/native/crates/app/src/update/tests.rs
+++ b/native/crates/app/src/update/tests.rs
@@ -170,6 +170,7 @@ fn an_explicit_check_without_an_update_says_so_once(cx: &mut gpui::TestAppContex
}
#[gpui::test]
+#[cfg(target_os = "macos")]
fn a_read_only_bundle_fails_the_check_with_squirrels_message_when_explicit(cx: &mut gpui::TestAppContext) {
let bundle = PathBuf::from("/System/Applications/Calculator.app");
let (service, events) = service_with(Ok(Config { update_url: "http://127.0.0.1:9".into(), build: build(), bundle, staging: std::env::temp_dir().join("vsrustium-service-unused") }), cx);
@@ -227,6 +228,7 @@ fn a_metered_connection_defers_the_automatic_check_until_it_is_not_metered(cx: &
}
#[gpui::test]
+#[cfg(target_os = "macos")]
fn an_update_found_on_a_metered_connection_waits_for_download(cx: &mut gpui::TestAppContext) {
let bundle = writable_bundle("metered-download");
let body = String::from_utf8(release("bbbb", "1.149.0", 2_000)).unwrap();
@@ -253,6 +255,7 @@ fn an_update_found_on_a_metered_connection_waits_for_download(cx: &mut gpui::Tes
}
#[gpui::test]
+#[cfg(target_os = "macos")]
fn a_deferred_download_starts_once_the_connection_is_not_metered(cx: &mut gpui::TestAppContext) {
let bundle = writable_bundle("metered-resume");
let (service, _) = service_with(Ok(config("http://127.0.0.1:9/feed.json".into(), &bundle)), cx);
@@ -271,6 +274,25 @@ fn a_deferred_download_starts_once_the_connection_is_not_metered(cx: &mut gpui::
});
}
+#[gpui::test]
+#[cfg(target_os = "linux")]
+fn an_update_found_on_linux_waits_and_download_opens_its_link(cx: &mut gpui::TestAppContext) {
+ let bundle = writable_bundle("linux-download");
+ let body = String::from_utf8(release("bbbb", "1.149.0", 2_000)).unwrap();
+ let reply: &'static str = Box::leak(format!("HTTP/1.1 200 OK\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{body}", body.len()).into_boxed_str());
+ let (url, _) = serve(Box::leak(Box::new([reply])));
+ let (service, _) = service_with(Ok(config(url, &bundle)), cx);
+ service.update(cx, |service, cx| {
+ service.reconfigure("manual", "latest", cx);
+ service.check_for_updates(true, cx);
+ });
+ cx.run_until_parked();
+ let State::AvailableForDownload { update } = service.read_with(cx, |service, _| service.state().clone()) else { panic!("no update found") };
+ service.update(cx, |service, cx| service.download_update(true, cx));
+ assert_eq!(cx.opened_url(), Some(update.url));
+ assert_eq!(service.read_with(cx, |service, _| service.state().type_name()), "idle");
+}
+
#[gpui::test]
fn restart_starts_only_from_ready_and_a_veto_puts_ready_back(cx: &mut gpui::TestAppContext) {
let bundle = writable_bundle("restart");
diff --git a/native/crates/app/src/windows_state.rs b/native/crates/app/src/windows_state.rs
index 8543a544ab3..be6677587b9 100644
--- a/native/crates/app/src/windows_state.rs
+++ b/native/crates/app/src/windows_state.rs
@@ -170,8 +170,12 @@ pub fn ui_state(window: &Window, cx: &App) -> UiState {
pub fn is_minimized(window: &Window) -> bool {
#[cfg(target_os = "macos")]
return crate::dialog::app_kit_window(window).is_some_and(|window| window.isMiniaturized());
+ // shortcut: GPUI has no minimized state on Linux, upgrade when gpui_linux exposes one.
#[cfg(not(target_os = "macos"))]
- false
+ {
+ let _ = window;
+ false
+ }
}
/// `validateWindowState`: the display and bounds to open a restored window with, none when its display is gone or
diff --git a/native/crates/app/src/workbench.rs b/native/crates/app/src/workbench.rs
index cbbd72ff59d..058f1919ff3 100644
--- a/native/crates/app/src/workbench.rs
+++ b/native/crates/app/src/workbench.rs
@@ -758,7 +758,7 @@ impl Workbench {
extension_commands: HashMap::new(),
skip_dialogs: false,
gallery_url: exthost::gallery::SERVICE_URL.into(),
- host_colors: themes::host_color_scheme(),
+ host_colors: themes::host_color_scheme(cx),
app_icon: None,
wait_files: Vec::new(),
restored_at: None,
diff --git a/native/crates/app/src/workbench/accessibility.rs b/native/crates/app/src/workbench/accessibility.rs
index b6bf75eca97..e728b0e215b 100644
--- a/native/crates/app/src/workbench/accessibility.rs
+++ b/native/crates/app/src/workbench/accessibility.rs
@@ -132,7 +132,7 @@ impl Workbench {
}
}
- /// `isMotionReduced`: `workbench.reduceMotion` on, or auto with the macOS Reduce Motion setting, read on each call
+ /// `isMotionReduced`: `workbench.reduceMotion` on, or auto with the OS reduce motion setting, read on each call
/// as Chromium's `prefers-reduced-motion` query follows it. Gates the `.monaco-enable-motion` animations.
pub(crate) fn is_motion_reduced(&self) -> bool {
match self.setting("workbench.reduceMotion").as_str() {
@@ -140,9 +140,8 @@ impl Workbench {
Some("off") => false,
#[cfg(target_os = "macos")]
_ => objc2_app_kit::NSWorkspace::sharedWorkspace().accessibilityDisplayShouldReduceMotion(),
- // Chromium on Linux follows GTK's gtk-enable-animations, not read yet.
#[cfg(target_os = "linux")]
- _ => false,
+ _ => crate::power::animations_disabled(),
}
}
@@ -544,14 +543,43 @@ pub(crate) fn screen_reader_running() -> bool {
objc2_app_kit::NSWorkspace::sharedWorkspace().isVoiceOverEnabled() || ASSISTIVE_APP_ENABLED.load(std::sync::atomic::Ordering::Relaxed)
}
-/// Chromium on Linux asks AT-SPI's `ScreenReaderEnabled`, not read yet.
+/// Chromium on Linux: AT-SPI's `org.a11y.Status` `ScreenReaderEnabled`, which Orca sets while it runs. Kept up to date
+/// by `watch_assistive_apps`.
#[cfg(target_os = "linux")]
pub(crate) fn screen_reader_running() -> bool {
- false
+ SCREEN_READER_ENABLED.load(std::sync::atomic::Ordering::Relaxed)
}
#[cfg(target_os = "linux")]
-pub(crate) fn watch_assistive_apps(_cx: &mut gpui::App) {}
+static SCREEN_READER_ENABLED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
+
+/// Watches `ScreenReaderEnabled` on the AT-SPI bus launcher, redrawing the windows when it changes. Run once at startup.
+#[cfg(target_os = "linux")]
+pub(crate) fn watch_assistive_apps(cx: &mut gpui::App) {
+ use futures::StreamExt;
+ use std::sync::atomic::Ordering;
+ let (sender, mut changes) = futures::channel::mpsc::unbounded();
+ std::thread::spawn(move || {
+ let status = zbus::blocking::Connection::session().and_then(|session| zbus::blocking::Proxy::new(&session, "org.a11y.Bus", "/org/a11y/bus", "org.a11y.Status"));
+ let Ok(status) = status else { return };
+ if status.get_property::<bool>("ScreenReaderEnabled").ok() == Some(true) {
+ SCREEN_READER_ENABLED.store(true, Ordering::Relaxed);
+ drop(sender.unbounded_send(()));
+ }
+ for change in status.receive_property_changed::<bool>("ScreenReaderEnabled") {
+ let Ok(enabled) = change.get() else { continue };
+ if SCREEN_READER_ENABLED.swap(enabled, Ordering::Relaxed) != enabled && sender.unbounded_send(()).is_err() {
+ return;
+ }
+ }
+ });
+ cx.spawn(async move |cx| {
+ while changes.next().await.is_some() {
+ cx.update(|cx| cx.refresh_windows());
+ }
+ })
+ .detach();
+}
#[cfg(target_os = "macos")]
static ASSISTIVE_APP_ENABLED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
diff --git a/native/crates/app/src/workbench/perf_view.rs b/native/crates/app/src/workbench/perf_view.rs
index aefa4fe123f..35837db2317 100644
--- a/native/crates/app/src/workbench/perf_view.rs
+++ b/native/crates/app/src/workbench/perf_view.rs
@@ -2,7 +2,6 @@
//! with the system, the port's startup marks, the extension activation times and the raw marks of each source.
use std::path::PathBuf;
-use std::process::Command;
use gpui::{Context, Window};
@@ -124,17 +123,14 @@ fn system_info(machine: &Machine, screen_reader: bool, empty_workspace: bool) ->
}
/// `os.freemem()` on macOS: free pages times the page size (libuv's `uv_get_free_memory`).
+#[cfg(target_os = "macos")]
pub(crate) fn free_memory() -> f64 {
- let vm_stat = run("vm_stat", &[]);
+ let vm_stat = std::process::Command::new("vm_stat").output().map(|output| String::from_utf8_lossy(&output.stdout).into_owned()).unwrap_or_default();
let page_size = vm_stat.split("page size of ").nth(1).and_then(|rest| rest.split(' ').next()).and_then(|size| size.parse::<f64>().ok()).unwrap_or(16384.);
let free_pages = vm_stat.lines().find(|line| line.starts_with("Pages free:")).and_then(|line| line.split(':').nth(1)).and_then(|pages| pages.trim().trim_end_matches('.').parse::<f64>().ok()).unwrap_or_default();
free_pages * page_size
}
-fn run(program: &str, args: &[&str]) -> String {
- Command::new(program).args(args).output().map(|output| String::from_utf8_lossy(&output.stdout).into_owned()).unwrap_or_default()
-}
-
#[cfg(test)]
mod tests {
use super::{Machine, system_info, table};
diff --git a/native/crates/app/src/workbench/shell_command.rs b/native/crates/app/src/workbench/shell_command.rs
index 4c57648f759..d268bbf5d02 100644
--- a/native/crates/app/src/workbench/shell_command.rs
+++ b/native/crates/app/src/workbench/shell_command.rs
@@ -1,5 +1,5 @@
//! installActions.ts and nativeHostMainService.ts's macOS Shell Command: `/usr/local/bin/<applicationName>` links to
-//! the app's bin/code, which port/tools/package-app writes from code.sh.
+//! the app's bin/code, which port/tools/package-app writes from code.sh; on Linux `~/.local/bin/<applicationName>`.
use std::io::ErrorKind;
use std::path::{Path, PathBuf};
@@ -15,7 +15,7 @@ use crate::product;
impl Workbench {
pub(super) fn register_shell_command_commands(&mut self) {
self.commands.register("workbench.action.installCommandLine", |workbench, _, window, cx| {
- let link = shell_command_link(&workbench.app_root, Path::new("/usr/local/bin"));
+ let link = shell_command_link(&workbench.app_root, &command_folder());
cx.spawn_in(window, async move |_, cx| {
let installed = match link {
Ok(link) => install_shell_command(&link, cx).await,
@@ -27,7 +27,7 @@ impl Workbench {
Outcome::done()
});
self.commands.register("workbench.action.uninstallCommandLine", |workbench, _, window, cx| {
- let link = shell_command_link(&workbench.app_root, Path::new("/usr/local/bin"));
+ let link = shell_command_link(&workbench.app_root, &command_folder());
cx.spawn_in(window, async move |_, cx| {
let uninstalled = match link {
Ok(link) => uninstall_shell_command(&link, cx).await,
@@ -53,19 +53,45 @@ fn application_name() -> &'static str {
}
fn shell_command_link(app_root: &Path, bin: &Path) -> Result<ShellCommandLink, String> {
- let target = app_root.join("bin/code");
+ let target = shell_script(app_root);
if !target.exists() {
return Err(format!("Unable to find shell script in '{}'", target.display()));
}
Ok(ShellCommandLink { source: bin.join(application_name()), target })
}
+/// The app's command line script: package-app writes `<bundle>/Contents/Resources/app/bin/code`.
+#[cfg(target_os = "macos")]
+fn shell_script(app_root: &Path) -> PathBuf {
+ app_root.join("bin/code")
+}
+
+/// package-linux writes `bin/<applicationName>` beside `resources/app`, as VS Code's Linux archive.
+#[cfg(target_os = "linux")]
+fn shell_script(app_root: &Path) -> PathBuf {
+ app_root.ancestors().nth(2).unwrap_or(app_root).join("bin").join(application_name())
+}
+
+/// The folder in PATH the command goes to: on Linux the user's own, which needs no privileges and which the
+/// desktop file's `Exec=<applicationName>` finds.
+fn command_folder() -> PathBuf {
+ match cfg!(target_os = "linux") {
+ true => PathBuf::from(std::env::var_os("HOME").unwrap_or_default()).join(".local/bin"),
+ false => PathBuf::from("/usr/local/bin"),
+ }
+}
+
/// `installShellCommand`: unless the link is there already, always through `osascript` with administrator
-/// privileges; `Ok(false)` when the user cancelled the privileges prompt.
+/// privileges; `Ok(false)` when the user cancelled the privileges prompt. Linux, where upstream has no Shell
+/// Command, links into the user's own `~/.local/bin` without a prompt.
async fn install_shell_command(link: &ShellCommandLink, cx: &mut AsyncWindowContext) -> Result<bool, String> {
if is_installed(link).map_err(|error| error.to_string())? {
return Ok(true);
}
+ if cfg!(target_os = "linux") {
+ let installed = Command::new("/bin/sh").arg("-c").arg(install_script(link)).status().is_ok_and(|status| status.success());
+ return installed.then_some(true).ok_or_else(|| format!("Unable to install the shell command '{}'.", link.source.display()));
+ }
let message = format!("{} will now prompt with 'osascript' for Administrator privileges to install the shell command.", product::name_short());
if !confirm_escalation(&message, cx).await {
return Ok(false);
@@ -80,7 +106,7 @@ async fn uninstall_shell_command(link: &ShellCommandLink, cx: &mut AsyncWindowCo
match std::fs::remove_file(&link.source) {
Ok(()) => Ok(true),
Err(error) if error.kind() == ErrorKind::NotFound => Ok(true),
- Err(error) if error.kind() == ErrorKind::PermissionDenied => {
+ Err(error) if cfg!(target_os = "macos") && error.kind() == ErrorKind::PermissionDenied => {
let message = format!("{} will now prompt with 'osascript' for Administrator privileges to uninstall the shell command.", product::name_short());
if !confirm_escalation(&message, cx).await {
return Ok(false);
diff --git a/native/crates/app/src/workbench/shell_command/tests.rs b/native/crates/app/src/workbench/shell_command/tests.rs
index 1e49e797c90..8a74c48c23c 100644
--- a/native/crates/app/src/workbench/shell_command/tests.rs
+++ b/native/crates/app/src/workbench/shell_command/tests.rs
@@ -12,8 +12,8 @@ fn temp_dir(name: &str) -> PathBuf {
fn app_with_script(dir: &Path) -> PathBuf {
let app_root = dir.join("VSRustium.app/Contents/Resources/app");
- std::fs::create_dir_all(app_root.join("bin")).unwrap();
- std::fs::write(app_root.join("bin/code"), "#!/usr/bin/env bash\n").unwrap();
+ std::fs::create_dir_all(shell_script(&app_root).parent().unwrap()).unwrap();
+ std::fs::write(shell_script(&app_root), "#!/usr/bin/env bash\n").unwrap();
app_root
}
@@ -21,7 +21,7 @@ fn app_with_script(dir: &Path) -> PathBuf {
fn the_link_needs_the_apps_script() {
let dir = temp_dir("missing");
let error = shell_command_link(&dir, &dir.join("bin")).unwrap_err();
- assert_eq!(error, format!("Unable to find shell script in '{}'", dir.join("bin/code").display()));
+ assert_eq!(error, format!("Unable to find shell script in '{}'", shell_script(&dir).display()));
std::fs::remove_dir_all(&dir).unwrap();
}
diff --git a/native/crates/app/src/workbench/themes.rs b/native/crates/app/src/workbench/themes.rs
index a7e2fbd7144..51578093dde 100644
--- a/native/crates/app/src/workbench/themes.rs
+++ b/native/crates/app/src/workbench/themes.rs
@@ -34,18 +34,19 @@ pub struct HostColorScheme {
/// Electron's `nativeTheme.shouldUseDarkColors` and `shouldUseHighContrastColors` on macOS.
#[cfg(target_os = "macos")]
-pub fn host_color_scheme() -> HostColorScheme {
+pub fn host_color_scheme(_cx: &gpui::App) -> HostColorScheme {
let defaults = objc2_foundation::NSUserDefaults::standardUserDefaults();
let style = defaults.stringForKey(&objc2_foundation::NSString::from_str("AppleInterfaceStyle"));
let high_contrast = objc2_app_kit::NSWorkspace::sharedWorkspace().accessibilityDisplayShouldIncreaseContrast();
HostColorScheme { dark: style.is_some_and(|style| style.to_string() == "Dark"), high_contrast }
}
-/// shortcut: light without high contrast, the scheme Electron reports when it finds no GTK or portal preference;
-/// reading the portal's `color-scheme` is a port/todo.md Linux gap.
+/// Electron on Linux: dark from the xdg-desktop-portal `color-scheme`, which GPUI reads and watches;
+/// `shouldUseHighContrastColors` is macOS and Windows only, so never high contrast.
#[cfg(target_os = "linux")]
-pub fn host_color_scheme() -> HostColorScheme {
- HostColorScheme::default()
+pub fn host_color_scheme(cx: &gpui::App) -> HostColorScheme {
+ let dark = matches!(cx.window_appearance(), gpui::WindowAppearance::Dark | gpui::WindowAppearance::VibrantDark);
+ HostColorScheme { dark, high_contrast: false }
}
/// themeConfiguration.ts `getColorThemeSettingId`: the setting that names the color theme for this host scheme.
@@ -341,7 +342,7 @@ impl Workbench {
/// `hostColorService.onDidChangeColorScheme` with `isPreferredColorSchemeChange`.
pub fn host_color_scheme_changed(&mut self, cx: &mut Context<Self>) {
- let (previous, current) = (self.host_colors, host_color_scheme());
+ let (previous, current) = (self.host_colors, host_color_scheme(cx));
self.host_colors = current;
let settings = self.settings.lock().unwrap();
let enabled = |key| settings.get_value(Some(key), &Default::default()) == Some(json!(true));
diff --git a/native/crates/exthost/Cargo.toml b/native/crates/exthost/Cargo.toml
index d58c67181e7..2b72968bb9b 100644
--- a/native/crates/exthost/Cargo.toml
+++ b/native/crates/exthost/Cargo.toml
@@ -27,3 +27,11 @@ block2 = "0.6"
objc2 = "0.6"
objc2-foundation = { version = "0.3.2", default-features = false, features = ["NSArray", "NSData", "NSDate", "NSDictionary", "NSError", "NSObject", "NSString", "NSURL", "NSURLRequest", "NSURLResponse", "NSURLSession", "NSValue", "alloc", "block2"] }
security-framework = "3"
+
+[target.'cfg(target_os = "linux")'.dependencies]
+futures = "0.3"
+# The features gpui_linux enables, so one oo7 and one zbus build.
+oo7 = { version = "0.6", default-features = false, features = ["async-std", "native_crypto"] }
+
+[target.'cfg(target_os = "linux")'.dev-dependencies]
+async-lock = "3"
diff --git a/native/crates/exthost/src/main_thread_secret_state.rs b/native/crates/exthost/src/main_thread_secret_state.rs
index 0fdb8579eda..53bbec518fb 100644
--- a/native/crates/exthost/src/main_thread_secret_state.rs
+++ b/native/crates/exthost/src/main_thread_secret_state.rs
@@ -1,7 +1,8 @@
//! mainThreadSecretState.ts over the macOS Keychain. Upstream encrypts each secret with Electron safeStorage,
//! whose key lives in the Keychain, and keeps it in application storage under `secret://<key>`. The port stores
//! each secret as a generic password item instead: service `Code - OSS Secret Storage`, account the same
-//! `{"extensionId","key"}` key, so the Keychain encrypts it and no key handling is needed here.
+//! `{"extensionId","key"}` key, so the Keychain encrypts it and no key handling is needed here. On Linux each
+//! secret is a Secret Service item with the same `service` and `account` attributes (keytar's layout).
use std::collections::BTreeMap;
@@ -15,11 +16,11 @@ use serde_json::{Value, json};
use crate::rpc::{Arg, Message, Reply};
-/// Linux has no keychain here yet: secrets stay in memory, as secrets.ts does without encryption.
#[cfg(target_os = "linux")]
-type KeychainError = std::io::Error;
+use futures::executor::block_on;
+#[cfg(target_os = "linux")]
+use oo7::Error as KeychainError;
-#[cfg(target_os = "macos")]
const SERVICE: &str = "Code - OSS Secret Storage";
/// errSecItemNotFound.
#[cfg(target_os = "macos")]
@@ -32,14 +33,19 @@ pub struct MainThreadSecretState {
enum Secrets {
#[cfg(target_os = "macos")]
Keychain(SecKeychain),
+ #[cfg(target_os = "linux")]
+ Keyring(oo7::Keyring),
/// Extension tests: application storage is in memory, and so are the secrets kept in it.
Memory(BTreeMap<String, String>),
}
impl MainThreadSecretState {
+ /// The default collection of the Secret Service (gnome-keyring, KWallet), unlocked.
#[cfg(target_os = "linux")]
pub fn keychain() -> Result<Self, KeychainError> {
- Err(std::io::Error::new(std::io::ErrorKind::Unsupported, "the Secret Service is not supported yet"))
+ let keyring = block_on(oo7::Keyring::new())?;
+ block_on(keyring.unlock())?;
+ Ok(MainThreadSecretState { secrets: Secrets::Keyring(keyring) })
}
#[cfg(target_os = "macos")]
@@ -110,6 +116,11 @@ impl MainThreadSecretState {
Err(error) if error.code() == ITEM_NOT_FOUND => Ok(None),
Err(error) => Err(error),
},
+ #[cfg(target_os = "linux")]
+ Secrets::Keyring(keyring) => {
+ let Some(item) = block_on(keyring.search_items(&[("service", SERVICE), ("account", account)]))?.into_iter().next() else { return Ok(None) };
+ Ok(Some(String::from_utf8_lossy(&block_on(item.secret())?).into_owned()))
+ }
}
}
@@ -121,6 +132,8 @@ impl MainThreadSecretState {
}
#[cfg(target_os = "macos")]
Secrets::Keychain(keychain) => keychain.set_generic_password(SERVICE, account, value.as_bytes()),
+ #[cfg(target_os = "linux")]
+ Secrets::Keyring(keyring) => block_on(keyring.create_item(SERVICE, &[("service", SERVICE), ("account", account)], value, true)),
}
}
@@ -137,14 +150,29 @@ impl MainThreadSecretState {
Err(error) if error.code() == ITEM_NOT_FOUND => Ok(false),
Err(error) => Err(error),
},
+ #[cfg(target_os = "linux")]
+ Secrets::Keyring(keyring) => {
+ let items = block_on(keyring.search_items(&[("service", SERVICE), ("account", account)]))?;
+ for item in &items {
+ block_on(item.delete())?;
+ }
+ Ok(!items.is_empty())
+ }
}
}
/// The account of every secret, for `secretStorageService.keys()`.
#[cfg(target_os = "linux")]
fn accounts(&self) -> Result<Vec<String>, KeychainError> {
- let Secrets::Memory(secrets) = &self.secrets;
- Ok(secrets.keys().cloned().collect())
+ let keyring = match &self.secrets {
+ Secrets::Memory(secrets) => return Ok(secrets.keys().cloned().collect()),
+ Secrets::Keyring(keyring) => keyring,
+ };
+ let mut accounts = Vec::new();
+ for item in block_on(keyring.search_items(&[("service", SERVICE)]))? {
+ accounts.extend(block_on(item.attributes())?.remove("account"));
+ }
+ Ok(accounts)
}
/// The account of every secret, for `secretStorageService.keys()`.
@@ -217,6 +245,15 @@ mod tests {
std::fs::remove_dir_all(&dir).unwrap();
}
+ /// oo7's file backend, the one it uses inside a Flatpak, stands in for the Secret Service.
+ #[test]
+ #[cfg(target_os = "linux")]
+ fn secrets_in_a_keyring() {
+ let file = block_on(oo7::file::UnlockedKeyring::temporary(oo7::Secret::text("test"))).unwrap();
+ let keyring = oo7::Keyring::File(std::sync::Arc::new(async_lock::RwLock::new(Some(oo7::file::Keyring::Unlocked(file)))));
+ check_flow(&mut MainThreadSecretState { secrets: Secrets::Keyring(keyring) });
+ }
+
#[test]
fn secrets_in_memory() {
check_flow(&mut MainThreadSecretState::in_memory());
diff --git a/native/crates/exthost/src/request/linux.rs b/native/crates/exthost/src/request/linux.rs
index 19dcf973e14..4de2edcab19 100644
--- a/native/crates/exthost/src/request/linux.rs
+++ b/native/crates/exthost/src/request/linux.rs
@@ -32,10 +32,8 @@ pub(super) fn send(options: &Request, proxy: Option<&SessionProxy>, proxy_author
let (scheme, address) = proxy.rules.split_once("://").unwrap_or(("http", &proxy.rules));
// Chromium's `socks` is SOCKS4.
let scheme = if scheme == "socks" { "socks4" } else { scheme };
- // `<local>` (names without a dot) has no curl counterpart and is left out.
- let bypass: Vec<&str> = proxy.bypass_rules.split(',').map(str::trim).filter(|rule| !rule.is_empty() && *rule != "<local>").collect();
curl.arg("--proxy").arg(if address.is_empty() { String::new() } else { format!("{scheme}://{address}") });
- curl.arg("--noproxy").arg(bypass.join(","));
+ curl.arg("--noproxy").arg(no_proxy(&proxy.bypass_rules, options.url));
}
if let Some(authorization) = proxy_authorization {
curl.arg("--proxy-header").arg(format!("Proxy-Authorization: {authorization}"));
@@ -59,3 +57,35 @@ pub(super) fn send(options: &Request, proxy: Option<&SessionProxy>, proxy_author
let status = std::str::from_utf8(&status).ok().and_then(|status| status.parse().ok()).context("curl gave no status")?;
Ok(Response { status, body })
}
+
+/// curl's `--noproxy` for Chromium's bypass rules. curl has no `<local>` (a host name without a dot, not an IP
+/// literal), so the request's own host joins the list when it is one.
+fn no_proxy(bypass_rules: &str, url: &str) -> String {
+ let mut hosts: Vec<&str> = bypass_rules.split(',').map(str::trim).filter(|rule| !rule.is_empty() && *rule != "<local>").collect();
+ let host = url_host(url);
+ if bypass_rules.split(',').any(|rule| rule.trim() == "<local>") && !host.is_empty() && !host.contains(['.', ':', '[']) {
+ hosts.push(host);
+ }
+ hosts.join(",")
+}
+
+/// The host of `scheme://user@host:port/path`; an IPv6 literal gives `[`.
+fn url_host(url: &str) -> &str {
+ let rest = url.split_once("://").map_or(url, |(_, rest)| rest);
+ let authority = rest.split(['/', '?', '#']).next().unwrap_or_default();
+ let host = authority.rsplit_once('@').map_or(authority, |(_, host)| host);
+ host.split(':').next().unwrap_or(host)
+}
+
+#[cfg(test)]
+mod tests {
+ use super::no_proxy;
+
+ #[test]
+ fn local_bypasses_hosts_without_a_dot() {
+ assert_eq!(no_proxy("a.example,<local>", "http://intranet:8080/x"), "a.example,intranet");
+ assert_eq!(no_proxy("a.example,<local>", "https://[email protected]/"), "a.example");
+ assert_eq!(no_proxy("<local>", "http://[::1]:3000/"), "");
+ assert_eq!(no_proxy("a.example", "http://intranet/"), "a.example");
+ }
+}
diff --git a/port/ledger.md b/port/ledger.md
index d7c75e6c715..45f627832ac 100644
--- a/port/ledger.md
+++ b/port/ledger.md
@@ -42,24 +42,24 @@ Status: `open`, `in progress`, `waiting on Artur`, `later` (postponed), `done`,
| Milestones | M24 Windows build | later | After milestone 23, on the same seams: WebView2 (wry), the Win32 file dialogs, the in-window menu bar and custom title bar, Credential Manager (keyring), the user-setup install path and `code` on PATH, `%APPDATA%\Code` settings import, ConPTY for the terminal (alacritty_terminal has it), an x64 and arm64 zip and a user installer, no Authenticode signing (the Windows signing decision). Builds on a GitHub Actions `windows` runner. | As milestone 23, for win32-x64 and win32-arm64. |
| Milestones | M25 virtual workspaces | later | Artur: its own milestone after M20, not part of the gap audits. A folder of a non-file scheme (`.code-workspace` `uri` folders, `--folder-uri`, `vscode.openFolder` with an extension file system provider scheme) kept as a URI; every reader of workspace folders (173 `.folders` uses in 70 files: explorer, search, quick open, terminal cwd, tasks, git, watcher, settings layers, trust) goes through the file system providers; the workspace marked virtual, `virtualWorkspaces: false` extensions disabled with the `notSupportedInWorkspace` message (config/workspace.rs:101, port/notes.md provider entries deferred until virtual workspaces). | not started |
| M23 Linux | app/src/webview/linux.rs:14 | open | [linux L] webviews through WebKitGTK (wry): webview panels and views, editor insets, notebook outputs, extension details, release notes. Linux shows now: no webview: `supported()` is false and each webview surface stays empty. | |
-| M23 Linux | exthost/src/main_thread_secret_state.rs:46 | open | [linux M] secrets in the Secret Service (libsecret). Linux shows now: secrets kept in memory, lost on quit. | |
+| M23 Linux | exthost/src/main_thread_secret_state.rs:46 | done | [linux M] secrets in the Secret Service (libsecret). | `cargo test -p exthost secret` on Linux: `secrets_in_a_keyring` (oo7's file backend); a desktop Secret Service not run |
| M23 Linux | app/src/clipboard.rs:97 | open | [linux M] clipboard file lists, HTML and other custom formats, the find text. Linux shows now: text only; the other formats read empty. | |
-| M23 Linux | app/src/workbench/themes.rs:47 | open | [linux S] host color scheme and high contrast from the xdg-desktop-portal Settings. Linux shows now: always light, never high contrast. | |
+| M23 Linux | app/src/workbench/themes.rs:47 | done | [linux S] host color scheme and high contrast from the xdg-desktop-portal Settings. | GPUI's `window_appearance()`, which gpui_linux reads from the portal's `color-scheme`; high contrast stays off, as Chromium on Linux |
| M23 Linux | app/src/dialog.rs:63 | open | [linux M] native message box (GTK). Linux shows now: the custom workbench dialog. | |
| M23 Linux | app/src/system_wide_keybindings/linux.rs:20 | open | [linux M] system-wide keybindings (xdg-desktop-portal GlobalShortcuts, X11 grabs). Linux shows now: registration fails. | |
-| M23 Linux | app/src/power/linux.rs:8 | open | [linux M] powerMonitor: idle time, lock state, battery, sleep and resume events, power save blockers (logind). Linux shows now: idle 0, never locked, on AC, no events, blockers return an id but hold nothing. | |
-| M23 Linux | app/src/accessibility_signals.rs:119 | open | [linux S] accessibility signal sounds. Linux shows now: no sound, an error in the log. | |
-| M23 Linux | app/src/metered_connection.rs:57 | open | [linux S] metered connection (NetworkManager). Linux shows now: never metered. | |
+| M23 Linux | app/src/power/linux.rs:8 | done | [linux M] powerMonitor: idle time, lock state, battery, sleep and resume events, power save blockers (logind). | `cargo test -p app power::` on Linux; the D-Bus calls (logind, UPower, ScreenSaver, Mutter) not run on a desktop |
+| M23 Linux | app/src/accessibility_signals.rs:119 | done | [linux S] accessibility signal sounds. | `pw-play`, else `paplay`; not run with audio in the container |
+| M23 Linux | app/src/metered_connection.rs:57 | done | [linux S] metered connection (NetworkManager). | NetworkManager `Metered` over D-Bus; not run on a desktop |
| M23 Linux | app/src/keyboard_layout/linux.rs:8 | open | [linux M] keyboard layout info and raw mapping (xkbcommon). Linux shows now: empty layout, US scan code fallback. | |
| M23 Linux | app/src/workbench/host.rs:330 | open | [linux S] always on top. Linux shows now: the commands do nothing, the context key stays false. | |
-| M23 Linux | app/src/workbench/accessibility.rs:531 | open | [linux S] screen reader and reduced motion detection (AT-SPI, portal). Linux shows now: never on. | |
-| M23 Linux | app/src/file_dialog.rs:28 | open | [linux S] dialog title, button label, filters and default folder in the portal file chooser. Linux shows now: the portal chooser with its defaults. | |
-| M23 Linux | exthost/src/request/linux.rs:24 | open | [linux S] the `<local>` proxy bypass rule. Linux shows now: left out of `--noproxy`. | |
-| M23 Linux | app/src/workbench/shell_command.rs:65 | open | [linux S] `code` CLI install to `~/.local/bin`. Linux shows now: the macOS osascript install. | |
-| M23 Linux | app/src/update/install.rs:51 | open | [linux M] updates as a download link (no in-place install). Linux shows now: the macOS ditto and codesign install. | |
-| M23 Linux | app/src/diagnostics.rs:308 | open | [linux S] machine info from `/proc` (CPU model, memory, release). Linux shows now: sysctl fails, fields empty. | |
+| M23 Linux | app/src/workbench/accessibility.rs:531 | done | [linux S] screen reader and reduced motion detection (AT-SPI, portal). | AT-SPI `ScreenReaderEnabled` and the portal's `enable-animations` over D-Bus; not run on a desktop |
+| M23 Linux | app/src/file_dialog.rs:28 | open | [linux S] dialog title, filters and the open dialog's default folder in the portal file chooser (GPUI's `PathPromptOptions` carries only the button label, which it now gets). Linux shows now: the portal chooser's title, no filters, its last folder. | |
+| M23 Linux | exthost/src/request/linux.rs:24 | done | [linux S] the `<local>` proxy bypass rule. | `cargo test -p exthost request::linux` on Linux: `local_bypasses_hosts_without_a_dot` |
+| M23 Linux | app/src/workbench/shell_command.rs:65 | done | [linux S] `code` CLI install to `~/.local/bin`. | `cargo test -p app shell_command` on Linux |
+| M23 Linux | app/src/update/install.rs:51 | done | [linux M] updates as a download link (no in-place install). | `cargo test -p app update::` on Linux: `an_update_found_on_linux_waits_and_download_opens_its_link` |
+| M23 Linux | app/src/diagnostics.rs:308 | done | [linux S] machine info from `/proc` (CPU model, memory, release). | `cargo test -p app diagnostics` on Linux: `linux_machine_reads_proc` |
| M23 Linux | app/src/workbench/menubar.rs:173 | open | [linux M] menu bar in the custom title bar. Linux shows now: no menu bar; gpui_linux `set_menus` keeps the menus and draws none. | |
-| M23 Linux | .github/workflows/linux.yml:1 | open | [linux S] move actions/checkout, actions/setup-node and actions/upload-artifact from v4 to their Node 24 majors (pinned by SHA). Linux shows now: run 46222369725 warns that they target the deprecated Node 20 and runs them on Node 24. | |
+| M23 Linux | .github/workflows/linux.yml:1 | done | [linux S] move actions/checkout, actions/setup-node and actions/upload-artifact from v4 to their Node 24 majors (pinned by SHA). | checkout v7.0.1, setup-node v7.1.0, upload-artifact v7.0.2 by SHA; the workflow not run yet |
| M23 Linux | port/tools/package-linux:1 | done | [linux M] Linux builds of the host's native modules (@vscode/spdlog, kerberos): package-linux rebuilds them with node-gyp; a dev run in the Studio container still loads the reference's macOS builds (its pnpm install ran on macOS), a Linux install of upstream builds them for Linux. | the extracted `VSRustium-1.147.0-linux-arm64.tar.gz` writes `logs/<session>/window1/exthost/exthost.log` (spdlog) and passes `port/tools/linux/smoke` |
| M21 uplift | setup: reference | later | On the Studio: check out `1.148.0` in `~/Developer/vscode-ref`, run `npm ci`, compile it and its extensions (port/notes.md "Reference"), then run `port/tools/fetch-builtin-extensions` again. | `~/Developer/vscode-ref/package.json` names 1.148.0 and `port/tools/ref-screenshot` draws it |
| M21 uplift | setup: upstream checkout | later | `git -C upstream fetch origin tag 1.148.0 --no-tags`, then `git -C upstream checkout 1.148.0` (1.148.0 is not a descendant of 1.147.0: each release is its own branch). 1.148.0 does not change the files that the 9 `port/patches/*.patch` and the `product.json` overlay touch. Rebuild the extension host. | `git -C upstream apply --check port/patches/*.patch`; `port/tools/build-exthost` |
diff --git a/port/notes.md b/port/notes.md
index 5f5f45a7e95..3c7ca409e7c 100644
--- a/port/notes.md
+++ b/port/notes.md
@@ -982,6 +982,11 @@ What to do (milestone 21, in order):
- Tests that read the platform: readdir order (APFS sorts, ext4 and overlayfs do not), the default shell's profile icon (`terminal` for zsh, `terminal-bash` for bash), GPUI's `super` for the platform key, and the settings import fixture's `.config` link to its `Library/Application Support`.
- Local history date labels use chrono's `%B %-d, %Y at %-I:%M %p` on both systems, the text V8's `Intl.DateTimeFormat('en')` prints (NSDateFormatter needed U+202F and `/` fixes); `date_labels_read_as_the_english_intl_format` checks it.
- Package (`port/tools/package-linux`, the app files from `port/tools/app-files.ts`): `VSRustium-linux-<arch>/` as VS Code's Linux archive lays it out, the release binary named `applicationName` (debug info stripped: `debug = "limited"` stays in the ELF on Linux, 571 MB with it) beside bun, `bin/vsrustium` from upstream's `resources/linux/bin/code.sh`, `com.rokartur.vsrustium.desktop` from upstream's `resources/linux/code.desktop` (Exec is `vsrustium` on PATH, as an archive does not know where it is unpacked; `StartupWMClass` is `product.linuxDesktopName`, which the windows set as their X11 WM_CLASS and Wayland app id) with `vsrustium.png` (`port/AppIcon.png`, ictool's 512 px render of `port/AppIcon.icon`), the app files in `resources/app` (`product::BUNDLED_APP`, which the binary takes as its root when it is there). Native modules built for another system or arch are rebuilt with node-gyp from their source; a binding.gyp that builds nothing on Linux (@vscode/fs-copyfile) leaves the module out, any other foreign binary fails the package. It writes `VSRustium-<version>-linux-<arch>.tar.gz` and the `linux-<arch>.json` and `linux-<arch>-prerelease.json` feed entries (`gallery::CURRENT_TARGET_PLATFORM` is `linux-<arch>` on Linux, for the gallery and the update feed). arm64 1.147.0: folder 412 MB, archive 131 MB; the extracted archive passes `port/tools/linux/smoke` with `APP=<folder>/vsrustium` in a container without the reference mounted. linux-x64 builds on GitHub Actions (`.github/workflows/linux.yml`, run by hand, the README's build steps with upstream's pnpm install building the native modules for Linux). The binary needs the glibc it links: GLIBC_2.39 for both (Debian 13's container, the ubuntu-24.04 runner; ubuntu-latest, 26.04, asked for 2.43 and the x64 package did not start on Debian 13).
+- Desktop services over D-Bus (zbus 5, the one gpui_linux's ashpd and oo7 build; blocking proxies on their own threads, each service optional): power (`power/linux.rs`) takes idle time from Mutter's IdleMonitor, else the ScreenSaver service's `GetSessionIdleTime`; the lock state from logind's session `LockedHint`; the power source from UPower's `OnBattery`; `prevent-display-sleep` is a ScreenSaver `Inhibit` cookie and `prevent-app-suspension` a logind `sleep` inhibitor fd; the events are logind's `PrepareForSleep` and `PrepareForShutdown`, as Electron has no lock, battery, thermal or speed limit events on Linux. A blocker the bus refuses still counts as started, as Electron's map of ids. Metered is NetworkManager's `Metered` (`YES` or `GUESS_YES`), the screen reader AT-SPI's `org.a11y.Status` `ScreenReaderEnabled`, reduced motion the portal's `org.gnome.desktop.interface` `enable-animations` (Chromium follows GTK's `gtk-enable-animations`). None of these ran against a desktop session yet: the container has no session or system bus.
+- Secrets (`exthost/src/main_thread_secret_state.rs`) are Secret Service items of the default collection through oo7 (gpui_linux's version and features), with keytar's `service` and `account` attributes; the test runs the flow on oo7's file keyring.
+- Updates follow updateService.linux.ts: a found build waits in AvailableForDownload (no metered deferral, no Squirrel read-only check) and Download opens product.json `downloadUrl`, else the update's url, and goes back to Idle. The running build counts as installed when its executable sits beside `resources/app`.
+- Accessibility signal sounds run `pw-play`, else `paplay` (both decode mp3 through libsndfile 1.1 or later), one process per sound file, killed when the sound replays.
+- The `code` shell command on Linux links `~/.local/bin/<applicationName>` to the archive's `bin/<applicationName>` without a privilege prompt (upstream has the command on macOS only; a Linux package puts it on PATH itself). Proxy `<local>` adds the request's host to `--noproxy` when it has no dot, curl has no such rule. Machine info reads `/proc/cpuinfo`, `/proc/meminfo` and the cpufreq `scaling_cur_freq`.
## Accepted platform differences