Skip to content

kai-tub/hypr-window-switcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hypr-window-switcher

Do you love Hyprland, the awesome tiling compositor, and the flexibility and configuration it offers, but are missing a simple tool to switch to a specific window quickly? Maybe hypr-window-switcher is what you are looking for!

hypr-window-switcher.mp4

hypr-window-switcher is a tiny script that wraps around fuzzel to list all currently open windows, making it easy to switch to the desired window using fzuzy matching! hypr-window-switcher will also take care of those pesky hidden windows and still work as expected, even when the desired window is hidden behind a fullscreen window. ;)

Installation

The project's repository provides a NixOS module, making it a breeze to install and configure:

inputs = {
  # ...your inputs
  hypr-window-switcher = "github:kai-tub/hypr-window-switcher";
};
outputs = {
  # ...your outputs
  hypr-window-switcher
}:
# skipping until your main config:
  imports = [
    # ... your imports
    hypr-window-switcher.nixosModules.default
  ];
  # simply enable it to install it!
  programs.hypr-window-switcher = {
    enable = true;
    # Move cursor to the lower-right corner after focus
    extra_dispatches = [ "dispatch movecursortocorner 2" ];
  };
  # Then you can add the command `hypr-window-switcher`
  # to your Hyprland keybindings!

However, if you're not a NixOS user, you'll have to install the following dependencies manually:

Then, copy the repository's script from the src directory to a directory that is accessible by your PATH.

Configuration

To allow customizing the hyprctl batch call, additional hyprctl dispatch commands can be configured to run after switching to the target window. For example:

dispatch movecursortocorner 1;

can be used to move the cursor to the lower-right corner of the newly focused window.

Configuration -- NixOS

The programs.hypr-window-switcher module provides the module option extra_dispatches that expects a list of strings of dispatch commands, like: programs.hypr-window-switcher.extra_dispatches = ["dispatch movecursortocorner 1"];

Configuration -- Manual

hypr-window-switcher will try to read a single line from the ~/$XDG_CONFIG_HOME/hypr-window-switcher/extra_dispatches.txt (default ~/.config/...) UTF-8 encoded file or if this file cannot be found from /etc/hypr-window-switcher/extra_dispatches.txt. The contents of the file might look like:

dispatch movecursortocorner 1;

Testing

NixOS VM tests are used to ensure that the script works as expected. The test will start a VM with a fresh NixOS install and run a real Hyprland session in the background. Different Wayland applications will be started within the VM, and the test script will check if the hypr-window-switcher correctly focuses on the entered target window. Resulting in a real integration test 🎉 See the flake.nix file for more details.

ToDo:

  • Potentially use bubblewrap to provide a safer/stricter execution
  • Maybe move to IP C instead of manually invoking hyprctl

About

A tiny Hyprland script to dmenu-style switch to other windows

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published