Skip to content

Repository files navigation

SnapToWindow

A cross-platform (windows, macOS) window management application inspired by Rectangle. Snap windows to predefined positions using keyboard shortcuts.

Built with Tauri, Rust, and TypeScript for native performance and a small footprint.

Features

  • Window Snapping: Snap windows to halves, quarters, thirds, and more
  • Keyboard Shortcuts: Customizable hotkeys for all window actions
  • System Tray: Runs quietly in the background with a system tray icon
  • Cross-Platform: Works on Windows and macOS (Linux support planned)
  • Lightweight: Minimal resource usage thanks to Tauri
  • Auto-Update: Seamless background updates with Tauri's updater plugin
  • Launch at Login: Optional auto-start when your computer boots

Supported Window Positions

Action Windows macOS
Left Half Ctrl + Alt + Left ⌃ + ⌥ + Left
Right Half Ctrl + Alt + Right ⌃ + ⌥ + Right
Top Half Ctrl + Alt + Up ⌃ + ⌥ + Up
Bottom Half Ctrl + Alt + Down ⌃ + ⌥ + Down
Top Left Quarter Ctrl + Alt + U ⌃ + ⌥ + U
Top Right Quarter Ctrl + Alt + I ⌃ + ⌥ + I
Bottom Left Quarter Ctrl + Alt + J ⌃ + ⌥ + J
Bottom Right Quarter Ctrl + Alt + K ⌃ + ⌥ + K
Left Third Ctrl + Alt + D ⌃ + ⌥ + D
Center Third Ctrl + Alt + F ⌃ + ⌥ + F
Right Third Ctrl + Alt + G ⌃ + ⌥ + G
Left Two Thirds Ctrl + Alt + E ⌃ + ⌥ + E
Right Two Thirds Ctrl + Alt + R ⌃ + ⌥ + R
Center Ctrl + Alt + C ⌃ + ⌥ + C
Maximize Ctrl + Alt + Enter ⌃ + ⌥ + Enter
Next Display Ctrl + Alt + ] ⌃ + ⌥ + ]
Previous Display Ctrl + Alt + [ ⌃ + ⌥ + [

Note: ⌃ = Control, ⌥ = Option

Architecture

Cross-Platform Design

The application uses Rust traits to abstract platform-specific window management APIs:

src-tauri/
├── src/
│   ├── main.rs              # Application entry point
│   ├── lib.rs               # Library exports & plugin initialization
│   ├── commands.rs          # Tauri commands (IPC)
│   ├── hotkeys.rs           # Global hotkey registration
│   ├── tray.rs              # System tray management
│   ├── config.rs            # User configuration & shortcuts
│   └── window_manager/
│       ├── mod.rs           # WindowManager trait definition
│       ├── types.rs         # Rect, Window, Display, SnapPosition types
│       ├── windows.rs       # Windows implementation (Win32 API)
│       ├── macos.rs         # macOS implementation (Accessibility API)
│       └── linux.rs         # Linux implementation (X11/Wayland) [stub]

Tech Stack

Layer Technology
Frontend TypeScript, React, Tailwind CSS
Backend Rust, Tauri 2.0
Windows API windows-rs (Win32)
macOS API core-foundation, core-graphics, cocoa, objc
Build Cargo, npm, Vite

Development

Prerequisites

  • Rust (1.75+)
  • Node.js (20+)
  • Platform-specific requirements:
    • Windows: Visual Studio Build Tools 2022
    • macOS: Xcode Command Line Tools
    • Linux: To be confirmed

Setup

# Clone the repository
git clone https://github.com/chitaoling/snaptowindow.git
cd snaptowindow

# Install dependencies
npm install

# Run in development mode
npm run tauri dev

Building

# Build for production
npm run tauri build

Binaries will be output to src-tauri/target/release/bundle/.

Configuration

Configuration is stored in:

  • Windows: %APPDATA%\snaptowindow\config.json
  • macOS: ~/Library/Application Support/snaptowindow/config.json
  • Linux: ~/.config/snaptowindow/config.json

Platform Notes

macOS

Requires Accessibility permissions. On first launch, you'll be prompted to grant access in System Preferences > Privacy & Security > Accessibility.

Windows

No special permissions required. Works out of the box.

Linux (Planned)

Will support both X11 and Wayland compositors through conditional compilation.

Roadmap

  • Project setup
  • Core window management trait
  • macOS implementation (Accessibility API)
  • Windows implementation (Win32 API)
  • Global hotkey registration
  • System tray integration
  • Multi-monitor support
  • Settings UI
  • Linux support (X11)
  • Linux support (Wayland)
  • Custom shortcut configuration UI
  • Automatic updates
  • Launch at Login

Changelog

v0.1.21

  • Fixed snapped windows landing inset from screen edges on Windows — the invisible resize border is now measured per window and compensated for, so halves and quarters sit flush and share no gutter
  • Cross-monitor moves stay correct when the border width or DPI changes between displays

v0.1.20

  • Dependency and CI maintenance: npm/Cargo audit fixes, GitHub Actions upgraded for Node.js 24

v0.1.19

  • Upgraded React 19, Tailwind CSS 4, Vite 8, and TypeScript 6

v0.1.18

  • Added move window to next/previous display (Ctrl+Alt+] / Ctrl+Alt+[)
  • Windows are maximized on the target display
  • Displays cycle in left-to-right, top-to-bottom order

v0.1.17

  • Added "Launch at Login" toggle in system tray menu
  • Uses native checkmark indicator for toggle state
  • Syncs with system autostart settings (macOS Login Items, Windows Startup)

Contributing

Contributions are welcome!

License

Licensed under either of:

  • Apache License, Version 2.0
  • MIT license

at your option.

Acknowledgments

  • Rectangle - The inspiration for this project
  • Tauri - The framework making this possible

About

A cross-platform (windows, macOS) window management application. Snap windows to predefined positions using keyboard shortcuts.

Resources

Stars

67 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages