Alt tab for hyprland on nix os

:slight_smile:
First, I intentionally did not ask the Hyprland community about this, as they seem to oppose the concept of “alt-tab.”

Just curious what others are using to fill this function on Hyprland. Most solutions my searches have brought me to have run into caveats on NixOS for me.

I am currently using wofi for my menu

I am working with this command (POC):

hyprctl clients | rg ^Window | wofi --dmenu | awk '{print $2}' | xargs -I{} hyprctl dispatcher focuswindow "address:0x{}"

This works for the alt tab, but I would love something that looks/acts better.

Cheers.

I was trying out your POC. I don’t know if it’s because I’m on a different version, but I had to do hyprctl dispatch focuswindow. I don’t personally do anything like that, but the concept is interesting. To make it better, did you want to be able to hold alt and tab through while performing focuswindow on each entry as you go?

That is what I would like to do. The reason I was using the address was because when you just do focus window, with multiple instances of the same app, they appear as one, and you do not know which you will end up with. :slight_smile:

Inspired by your oneliner, I ended up mapping $mod, J to the execution of the following script:

temp="$(mktemp)"

window_program="$(\
  hyprctl clients -j\
  | jq 'map({ program: .class, address: .address })'\
  | tee "$temp"\
  | jq -r 'map(.program) | join("\n")'\
  | tofi --prompt-text "jump to:"\
)"

window_address="$(< "$temp" jq -r --arg p "$window_program" 'map(select(.program == $p))[0].address')"

hyprctl dispatch focuswindow "address:$window_address"

rm "$temp"

A couple of points:

  • You might notice that I use tofi, but the difference should not be too relevant.
  • My window titles are rather long, so I favored the “class” that contains the program’s name. That works well because I usually have only one window per program.
  • I found that address was polluting the display, so I use a temporary file to store the address and window’s class mapping
    and that with class names.

If anyone has an idea on how to achieve the same feat without using a temporary file, I would be glad to hear about it.

Minor update: Hyprshell on NixOS (installed from their flake) works great. github:H3rmt/hyprshell

My commit

:nerd_face: …or just

hyprland.conf:

bind = ALT, TAB, cyclenext,

(focus) ^

bind = ALT, TAB, swapnext,

(window) ^

but yes, it only works within 1 workspace and/or all the monitors connected to that 1 workspace