Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

niri-run-or-cycle

A simple "Run or Cycle" script for the Niri window manager.

Inspired by kde-run-or-cycle, this script allows you to launch an application if it's not running, or cycle through its open windows if it's already active.

Prerequisites

  • Niri
  • jq (for JSON processing)
  • bash

Installation

  1. Clone this repository or download the run-or-cycle.sh script.
  2. Give it execution permissions:
    chmod +x run-or-cycle.sh
  3. (Optional) Move it to a directory in your PATH, like ~/.local/bin/.

Usage

The script takes two arguments:

  • app_id: The ID of the application (e.g., com.mitchellh.ghostty, brave-browser).
  • execution_command: The command to launch the app if it's not running.
./run-or-cycle.sh "app_id" "command"

Example

To launch or cycle through Ghostty:

./run-or-cycle.sh "com.mitchellh.ghostty" "ghostty"

How to find the app_id

Run the following command in Niri to see all open windows and their app_id:

niri msg windows

Look for the app_id field of the window you want to control.

Niri Configuration (config.kdl)

You can bind the script to a key in your Niri configuration:

binds {
    Mod+Return { spawn "path/to/run-or-cycle.sh" "com.mitchellh.ghostty" "ghostty"; }
    Mod+B { spawn "path/to/run-or-cycle.sh" "brave-browser" "brave"; }
}

License

MIT License. See LICENSE for more details.

About

Launch, focus, or cycle between windows of any app with a single keyboard shortcut. Niri (Wayland).

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages