tauri-apps / tauri-apps/plugins-workspace
Specify where the Window State plugin's JSON file is stored
- Dominant language
- Rust
- Stars
- 1.8k
- Forks
- 602
- Avg merge
- 4d 14h
- Merged PRs (30d)
- 9
Description
### 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:**
```rust
pub fn with_dir>(self, dir: P) -> Self
```
**Example Usage:**
```rust
// 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()
```
Contributor guide
Assessment
This issue has not been assessed yet.