Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cycle through visible windows regardless of workspace #6678

Open
offsetcyan opened this issue Jun 26, 2024 · 4 comments
Open

Cycle through visible windows regardless of workspace #6678

offsetcyan opened this issue Jun 26, 2024 · 4 comments
Labels
enhancement New feature or request stale Not much going on

Comments

@offsetcyan
Copy link

Description

The cyclenext dispatcher gives the user the ability to change focus to another window in the same workspace. A user may however have multiple monitors, with multiple workspaces, each containing visible windows that the user would like to cycle between. Therefore a dispatcher that cycles focus to the next visible window regardless of workspace (cyclenextvisible perhaps) would provide useful functionality, allowing a user to cycle between windows that might otherwise require moving to use the mouse and returning to the keyboard.

@offsetcyan offsetcyan added the enhancement New feature or request label Jun 26, 2024
@Truenya
Copy link
Contributor

Truenya commented Jun 27, 2024

looks interesting to try

@dpredovic
Copy link

dpredovic commented Jun 27, 2024

I have a script for that:

#!/bin/bash

mapfile -t ARR < <(
	hyprctl clients -j |
          jq -r '
           sort_by(.monitor,.workspace.id) | 
          .[] | 
          select(.hidden==false) | 
          [.address,"\(.class) 󰖲 \(.title)"] | 
          @tsv'
)

size="${#ARR[@]}"
if [ "$size" -le 1 ]; then
	exit 1 # skip everything if we have 0 or 1 windows
fi

case "$1" in
menu)
	index=$(printf "%s\n" "${ARR[@]}" | cut -f2 | fuzzel -d --index)
	if [ -z "$index" ]; then
		exit 1
	fi
	;;
next)
	activeAddr=$(hyprctl activewindow -j | jq -r .address)
	# grep line number is 1 and not zero based, so we don't need to ++ for the next window index
	index=$(printf "%s\n" "${ARR[@]}" | cut -f1 | grep -n "$activeAddr" | cut -d: -f1)
	if [ "$index" -ge "$size" ]; then
		index=0
	fi
	;;
*)
	exit 1
	;;
esac

addr=$(printf "%s" "${ARR[index]}" | cut -f1)
hyprctl dispatch focuswindow address:"$addr"

You can use it with keybindings for simple "next window" motion and in "menu" mode.

You need jq for json parsing and some menu (fuzzel in my case) if you want to use the menu variant.

Otoh, native implementation (at least for the next/prev) would be nice :)

@Truenya
Copy link
Contributor

Truenya commented Jun 28, 2024

I'm on the road right now and haven't been able to debug multiple monitors for probably a week.

@offsetcyan @dpredovic could you please check if it works as intended? #6695

@offsetcyan
Copy link
Author

Sorry for the delay. I've tried it and the cyclenextvisible dispatcher cycles between the first two visible windows on a single display. If you have three windows and focus on the third, a single call will switch focus to the second window; then the first; then the second, then the first.

@vaxerski vaxerski added the stale Not much going on label Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale Not much going on
Projects
None yet
Development

No branches or pull requests

4 participants