Skip to content

riyasyash/NishKu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸͺŸ Nishku

Save and restore window positions across displays

Version Platform License Go Version Homebrew

Perfect for switching between different monitor setups (home vs office, docked vs undocked)

brew tap riyasyash/tools
brew install nishku

Features β€’ Installation β€’ Usage β€’ Documentation β€’ Contributing


Overview

Nishku is a command-line tool that captures and restores window positions and sizes on macOS. It's designed for people who frequently switch between different monitor configurations and want their window layouts to adapt automatically.

Why Nishku?

  • 🏠 Home/Office Setup: Different monitor configs? No problem.
  • πŸ’» Docked/Undocked: Seamlessly switch between laptop-only and multi-monitor.
  • 🎯 Smart Adaptation: Windows automatically adapt when displays change.
  • ⚑ Fast & Light: Single binary, no runtime dependencies.

Features

Core Capabilities

  • πŸ’Ύ Save window layouts as named profiles
  • πŸ”„ Restore layouts instantly with one command
  • πŸ–₯️ Multi-display support with automatic adaptation
  • 🎯 Smart window matching - handles multiple windows per app
  • πŸ“ Position + Size - captures both location and dimensions
  • πŸ”’ Secure & Private - local storage only, no network access

Smart Features

  • Hybrid Matching: Works with apps that have multiple windows (Chrome, iTerm2, VS Code)
  • Display Adaptation: Automatically adjusts when monitors are disconnected
  • Bounds Checking: Ensures windows stay visible on screen
  • Built-in Diagnostics: nishku doctor checks your setup

Installation

Homebrew (Recommended)

The easiest way to install nishku on macOS:

brew tap riyasyash/tools
brew install nishku

Download Binary

Download the latest release from GitHub Releases:

# Apple Silicon (M1/M2/M3)
curl -L https://github.com/riyasyash/nishku/releases/latest/download/nishku-darwin-arm64.tar.gz | tar xz
sudo mv nishku /usr/local/bin/

# Intel Mac
curl -L https://github.com/riyasyash/nishku/releases/latest/download/nishku-darwin-amd64.tar.gz | tar xz
sudo mv nishku /usr/local/bin/

Using Go Install

go install github.com/riyasyash/nishku@latest

From Source

# Clone the repository
git clone https://github.com/riyasyash/nishku
cd nishku

# Build and install
make build
sudo make install

# Verify installation
nishku version

Requirements

  • macOS 10.14 (Mojave) or later
  • ~5MB disk space
  • Accessibility permissions (one-time setup)

Quick Start

1. Install

brew tap riyasyash/tools
brew install nishku

2. Check Your Setup

nishku doctor

This will show your current status and guide you through any required setup.

2. Grant Accessibility Permissions

To move windows, nishku needs accessibility permissions:

  1. Open System Settings β†’ Privacy & Security β†’ Accessibility
  2. Click the πŸ”’ lock icon and authenticate
  3. Click the + button
  4. Add your terminal app (Terminal.app, iTerm.app, etc.)
  5. Enable the checkbox βœ“
  6. Restart your terminal

3. Save Your First Profile

# Save current window positions
nishku save work-setup

4. Restore Anytime

# Restore to saved layout
nishku load work-setup

Usage

Basic Commands

# Save current window layout
nishku save <profile-name>

# Restore window layout
nishku load <profile-name>

# List all profiles
nishku list

# Delete a profile
nishku delete <profile-name>

# Check setup and permissions
nishku doctor

# Show version
nishku version

Example Workflow

# At the office with dual monitors
nishku save office-dual-monitor

# At home with laptop only
nishku save home-laptop

# Switching between setups
nishku load office-dual-monitor  # When at office
nishku load home-laptop          # When at home

How It Works

Window Matching

Nishku uses a hybrid approach to match windows:

  1. Groups windows by application (e.g., all Chrome windows)
  2. Sorts by screen position (top-to-bottom, left-to-right)
  3. Assigns indices for reliable matching
  4. Matches on restore by app + window index

This means:

  • βœ“ Works with multiple windows per app
  • βœ“ Handles dynamic window titles (browser tabs, document names)
  • βœ“ Gracefully skips windows if app isn't running

Display Adaptation

When your display configuration changes:

  • Stores both absolute and relative positions
  • Adapts automatically if displays are missing
  • Ensures visibility - windows never go off-screen
  • Silent operation - no prompts or warnings needed

Example: Profile saved with 2 monitors, restored with 1 monitor:

  • Windows from Display 1 β†’ Restored to same position
  • Windows from Display 2 β†’ Moved to primary display (equivalent relative position)

Documentation

Platform Support

Platform Status Notes
macOS (Apple Silicon) βœ… Supported arm64
macOS (Intel) βœ… Supported amd64
Linux 🚧 Planned X11/Wayland support coming
Windows 🚧 Planned Win32 API support coming

Known Limitations

⚠️ Alpha Release - This is v0.0.1, expect some rough edges

  • Requires accessibility permissions (macOS security requirement)
  • Apps must be running before restore (doesn't launch apps)
  • Minimized windows may not restore correctly
  • Full-screen windows may exit full-screen when restored
  • Some system apps don't support Accessibility API

Troubleshooting

"Cannot move windows"

Run nishku doctor and follow the permission instructions. Make sure to restart your terminal after granting permissions.

"Skipped N windows"

This is normal when:

  • Profile has more windows than currently open
  • App isn't running
  • Window index doesn't exist

Windows not moving

  1. Check permissions: nishku doctor
  2. Verify app is running
  3. Try with a single-window app first
  4. See TESTING.md for detailed troubleshooting

Development

Building

# Build for current platform
make build

# Build for all platforms
make build-all

# Run tests
make test

# Format code
make fmt

Version Management

# Build with version
VERSION=v0.0.1 make build

# Check version
./nishku version --verbose

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

Areas for Contribution

  • 🐧 Linux support (X11/Wayland)
  • πŸͺŸ Windows support (Win32 API)
  • πŸ§ͺ Testing and bug reports
  • πŸ“š Documentation improvements
  • ✨ Feature suggestions

Development Setup

git clone https://github.com/riyasyash/nishku
cd nishku
make deps
make build
./nishku doctor

License

MIT License - see LICENSE file for details.

Acknowledgments

  • Built with Go
  • CLI powered by Cobra
  • Uses macOS CoreGraphics and Accessibility APIs

Author

Created by Riyas Yash

Support


Made with ❀️ for productivity enthusiasts

About

Nishku is a command-line tool that captures and restores window positions and sizes on macOS. It's designed for people who frequently switch between different monitor configurations and want their window layouts to adapt automatically.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors