diff options
| author | Israel Araújo de Oliveira <[email protected]> | 2026-02-09 06:00:35 -0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-02-09 17:00:35 +0800 |
| commit | 93a11ddedf697c9b673dd59628cee3db48ac67d0 (patch) | |
| tree | eaa37846d594604d49afb0333662df453103e88f /packages/desktop/src-tauri/src/linux_display.rs | |
| parent | 94feb811ca32f4e01a1bada9cfbc022e8d5ca9e3 (diff) | |
| download | opencode-93a11ddedf697c9b673dd59628cee3db48ac67d0.tar.gz opencode-93a11ddedf697c9b673dd59628cee3db48ac67d0.zip | |
feat(desktop): add native Wayland toggle on Linux (#11971)
Co-authored-by: Brendan Allan <[email protected]>
Diffstat (limited to 'packages/desktop/src-tauri/src/linux_display.rs')
| -rw-r--r-- | packages/desktop/src-tauri/src/linux_display.rs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/packages/desktop/src-tauri/src/linux_display.rs b/packages/desktop/src-tauri/src/linux_display.rs new file mode 100644 index 000000000..9e1cf9091 --- /dev/null +++ b/packages/desktop/src-tauri/src/linux_display.rs @@ -0,0 +1,47 @@ +use serde::{Deserialize, Serialize}; +use serde_json::json; +use std::path::PathBuf; +use tauri::AppHandle; +use tauri_plugin_store::StoreExt; + +use crate::constants::SETTINGS_STORE; + +pub const LINUX_DISPLAY_CONFIG_KEY: &str = "linuxDisplayConfig"; + +#[derive(Default, Serialize, Deserialize)] +struct DisplayConfig { + wayland: Option<bool>, +} + +fn dir() -> Option<PathBuf> { + Some(dirs::data_dir()?.join("ai.opencode.desktop")) +} + +fn path() -> Option<PathBuf> { + dir().map(|dir| dir.join(SETTINGS_STORE)) +} + +pub fn read_wayland() -> Option<bool> { + let path = path()?; + let raw = std::fs::read_to_string(path).ok()?; + let config = serde_json::from_str::<DisplayConfig>(&raw).ok()?; + config.wayland +} + +pub fn write_wayland(app: &AppHandle, value: bool) -> Result<(), String> { + let store = app + .store(SETTINGS_STORE) + .map_err(|e| format!("Failed to open settings store: {}", e))?; + + store.set( + LINUX_DISPLAY_CONFIG_KEY, + json!(DisplayConfig { + wayland: Some(value), + }), + ); + store + .save() + .map_err(|e| format!("Failed to save settings store: {}", e))?; + + Ok(()) +} |
