Hyprland
Hyprland copied to clipboard
Using `movefocus` to navigate inside group
Hi,
Coming from i3, I am used to using the normal focus keybindings for moving inside the "tabs" or (groups in hyperland).
I was wondering if the same thing can be done in hyperland (I know inside a group you can use changegroupactive
but I have not found a way to use the same key bindings for changing focus both inside and outside groups).
In case this is not possible as of now, could you consider adding this feature?
Thanks!
how would you move outside the group then?
When you are at the right/leftmost of the group and move right/left. Basically the way it works in i3 (I know hyprland is not supposed to be an i3 replacement but I do think this way of doing it is nice).
The same for me, it would be really cool to have the possibility to configure the same behavior for tab group. Using different hotkey is frustrating, can't find any comfortable key binding for that...
I worked around this with a simple script:
#!/bin/bash
groupSize=$(hyprctl activewindow -j | jq -r '.grouped | length')
if [[ "$groupSize" > 0 ]]; then
IN_GROUP=1
else
IN_GROUP=0
fi
if [[ "$1" == "left" ]]; then
if [[ "$IN_GROUP == 1 ]]; then
hyprctl dispatch changegroupactive b
else
hyprctl dispatch movefocus l
fi
else
if [[ "$IN_GROUP" == 1 ]]; then
hyprctl dispatch changegroupactive f
else
hyprctl dispatch movefocus r
fi
fi
then I bind it to my focus keys:
bind=SUPER,h,exec,~/.config/hypr/focus.sh left
bind=SUPER,l,exec,~/.config/hypr/focus.sh right
bind=SUPER,k,movefocus,u
bind=SUPER,j,movefocus,d
Yeah, you cannot leave the group, but I still have a mouse that can focus other things. Seems like an OK compromise. It'd be cool to be able to click on the group indicator to move focus within the group.
how would you move outside the group then?
@vaxerski: the way sway (and I believe i3) does it is using window trees. A group contains multiple windows, so to move out of it, (assuming you're currently in a window inside a group) you go a "level" up and now you're at the same level as the group (not its windows), allowing you to treat the group as a window and move anywhere from there.
pretty easily scriptable/pluginable
Not exactly scriptable. AFAIK, you can't have splits inside hypr groups. They're their own thing. You should try Sway for yourself to see what I'm talking about. The tree navigation feature can only be done inside hypr (or a plugin). This would unify all of the movements, making the movegroup
command family pointless.
I'm short on time to look into a script and/or plugin and I'm sure you have more important issues than this to work on, so if anyone develops anything like what I'm describing, please ping me! I'm interested :)
Btw loving hyprland
With #3683 this behavior is scriptable. See my comment for an example
Looks promising, thank you
For anyone that stumbles upon this issue, I have been using https://github.com/outfoxxed/hy3 and it solves this issue completely.
Thank you very much for this!
For posterity, I updated the shared bash script above to properly support leaving a group as well. Here's my updated bash script:
#!/bin/bash
data=$(hyprctl activewindow -j)
groupSize=$(echo "$data" | jq -r '.grouped | length')
address=$(echo "$data" | jq -r '.address')
groupIndex=$(echo $data | jq --arg address "$address" -r '.grouped | index($address)')
IN_GROUP=0
if [[ "$groupSize" > 0 ]]; then
IN_GROUP=1
fi
if [[ "$1" == "left" || "$1" == "l" ]]; then
if [[ "$IN_GROUP" == 1 && "$groupIndex" > 0 ]]; then
hyprctl dispatch changegroupactive b
else
hyprctl dispatch movefocus l
fi
else
if [[ "$IN_GROUP" == 1 && "$((groupIndex + 1))" < "$groupSize" ]]; then
hyprctl dispatch changegroupactive f
else
hyprctl dispatch movefocus r
fi
fi
For posterity, I updated the shared bash script above to properly support leaving a group as well. Here's my updated bash script:
#!/bin/bash data=$(hyprctl activewindow -j) groupSize=$(echo "$data" | jq -r '.grouped | length') address=$(echo "$data" | jq -r '.address') groupIndex=$(echo $data | jq --arg address "$address" -r '.grouped | index($address)') IN_GROUP=0 if [[ "$groupSize" > 0 ]]; then IN_GROUP=1 fi if [[ "$1" == "left" || "$1" == "l" ]]; then if [[ "$IN_GROUP" == 1 && "$groupIndex" > 0 ]]; then hyprctl dispatch changegroupactive b else hyprctl dispatch movefocus l fi else if [[ "$IN_GROUP" == 1 && "$((groupIndex + 1))" < "$groupSize" ]]; then hyprctl dispatch changegroupactive f else hyprctl dispatch movefocus r fi fi
Similarly you can replace changegroupactive
with movegroupwindow
and movefocus
with movewindoworgroup
for i3-like window moving/reordering in and out of groups. Though moving a window from the left into a group from the right doesn't insert it into the beginning of the group.