A plugin for tauri that helps positioning you windows at well known locations.
This plugin is a port of electron-positioner for tauri.
toml
[dependencies]
tauri-plugin-positioner = "0.1"
``` npm install github:JonasKruckenberg/tauri-plugin-positioner
yarn add github:JonasKruckenberg/tauri-plugin-positioner ```
You need to register the plugin first:
```rust use tauripluginpositioner::{Positioner, Position};
fn main() { tauri::Builder::default() .plugin(Positioner::default()) .build() .run(); } ```
Now you can import the JavaScript API package and move to window:
```javascript import { move_window, Position } from 'tauri-plugin-positioner-api'
move_window(Position.TopRight) ```
If you only intend on moving the window from rust code, you can just import the Window
trait extension instead of registering the plugin:
Note:
Window.move_window
method must be called from a different thread!
```rust use tauripluginpositioner::{WindowExt, Position};
fn main() { tauri::Builder::default() .setup(|app| { let mut win = app.get_window("main").unwrap();
// Call this method from a different thread
tauri::async_runtime::spawn(async move {
let _ = win.move_window(Position::TopRight);
});
Ok(())
})
.build()
.run();
} ```
PRs are welcome!