Skip to content

Specify where the Window State plugin's JSON file is stored #3020

@zevnda

Description

@zevnda

Problem

Currently, the Window State plugin saves the .window-state.json file in a fixed location: ${dataDir}/${bundleIdentifier}/. This creates issues for applications that need to maintain full portable installations where all data stays in the app/binary directory.

Proposed Solution

Add a with_dir() method to the Builder that allows specifying a custom directory for the window state file, similar to how with_filename() allows custom filenames.

Suggested API:

pub fn with_dir<P: AsRef<std::path::Path>>(self, dir: P) -> Self

Example Usage:

// Relative path
tauri_plugin_window_state::Builder::new()
    .with_state_flags(StateFlags::SIZE | StateFlags::POSITION)
    .with_dir("./config")
    .with_filename("my-window-state.json")
    .build()

// Absolute path
tauri_plugin_window_state::Builder::new()
    .with_state_flags(StateFlags::SIZE | StateFlags::POSITION)
    .with_dir("C:\\Users\\Username\\AppData\\Local\\MyApp")
    .with_filename("my-window-state.json")
    .build()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions