Files
komorebi/docs/usage/focusing-windows.md
T
LGUG2Z 20f93ba8c4 feat(wm): focus in a direction
A tiling window manager is driven from the keyboard, and the first thing a key
has to do is move the focus. `komorebic focus left|right|up|down` gives the
focus to the window whose tile is on that side of the focused one, as the layout
sees it, and `komorebic cycle-focus next|previous` to the next or the previous
window in the workspace's order, wrapping around. Neither moves a window: the
focus changes, the tiles stay.

The pointer follows the focus, through KWin's "Move Mouse to Focus", unless
`mouse-follows-focus disable` (or `toggle-mouse-follows-focus`) says not to.

Focusing towards a side with no window fails and changes nothing. Crossing into
the next monitor, as komorebi does on the other platforms, comes with more than
one monitor; so do eager-focus and the parts that depend on the monocle,
maximized and floating windows.

The VM test now drives the focus with komorebic in a real KWin and checks that
KWin and komorebi agree on the focused window afterwards.
2026-10-28 07:20:37 -07:00

58 lines
2.0 KiB
Markdown

# Focusing windows
komorebi gives the focus to another window of the focused workspace when it is told to. It
moves no window to do it: the windows stay on their tiles, and KWin makes the chosen one the
active window.
## In a direction
[`komorebic focus`](../cli/focus.md) focuses the window whose tile is on one side of the
focused one: `left`, `right`, `up` or `down`. Which tile is on which side is the layout's
business. In the BSP layout with three windows, for example, the first window has the left
half, and `focus right` from it goes to the window at the top right.
```sh
komorebic focus left
komorebic focus down
komorebic focus up
komorebic focus right
```
When there is no tile on that side, nothing happens, and the daemon logs "there is no container
in this direction".
## In order
[`komorebic cycle-focus`](../cli/cycle-focus.md) focuses the next or the previous window in the
order of the workspace, which is the order in which the windows were opened, each new one
after the window that had the focus. It wraps around: `next` from the last window is the
first.
```sh
komorebic cycle-focus next
komorebic cycle-focus previous
```
## The pointer
By default the pointer moves to the middle of the window that is given the focus. komorebi asks
KWin to do it with its "Move Mouse to Focus" shortcut, so the pointer follows only in a session
that has KWin's global shortcuts (a headless KWin has none).
[`komorebic mouse-follows-focus`](../cli/mouse-follows-focus.md) turns this on or off, and
[`komorebic toggle-mouse-follows-focus`](../cli/toggle-mouse-follows-focus.md) switches between
the two:
```sh
komorebic mouse-follows-focus disable
komorebic toggle-mouse-follows-focus
```
The setting is in the daemon's state as `mouse_follows_focus`, and it lasts until the daemon
stops.
## Binding them to keys
komorebi reads no keys. Bind the commands to keys in Plasma's System Settings, under Keyboard,
Shortcuts, as custom shortcuts that run a command: for example `Meta+H` for
`komorebic focus left` and `Meta+L` for `komorebic focus right`.