hyprland-wiki/pages/Configuring/Binds.md

276 lines
6.1 KiB
Markdown
Raw Normal View History

2022-10-20 22:54:34 +02:00
# Table of Contents
2022-09-24 15:32:40 +02:00
{{< toc >}}
2022-10-20 22:54:34 +02:00
# Basic
2022-09-24 15:32:40 +02:00
2022-09-24 16:03:37 +02:00
```ini
2022-09-24 15:32:40 +02:00
bind=MODS,key,dispatcher,params
```
for example,
2022-09-24 16:03:37 +02:00
```ini
2022-09-24 15:32:40 +02:00
bind=SUPER_SHIFT,Q,exec,firefox
```
will bind opening firefox to <key>SUPER</key> + <key>SHIFT</key> + <key>Q</key>
{{< hint type=tip >}}
For binding keys without a modkey, leave it empty:
2022-10-19 15:22:42 +02:00
2022-09-24 16:03:37 +02:00
```ini
2022-09-24 15:32:40 +02:00
bind=,Print,exec,grim
```
2022-10-19 15:22:42 +02:00
2022-09-24 15:32:40 +02:00
{{< /hint >}}
2022-10-19 15:22:42 +02:00
_For a complete mod list, see [Variables](../Variables/#variable-types)._
2022-10-19 15:22:42 +02:00
_The dispatcher list can be found in [Dispatchers](../Dispatchers)._
2022-09-24 15:32:40 +02:00
2022-10-20 22:54:34 +02:00
# Uncommon syms / binding with a keycode
2022-09-24 15:32:40 +02:00
See the
[xkbcommon-keysyms.h header](https://github.com/xkbcommon/libxkbcommon/blob/master/include/xkbcommon/xkbcommon-keysyms.h)
for all the keysyms. The name you should use is the one after `XKB_KEY_`,
written in all lowercase.
If you are unsure of what your key's name is, or what it shifts into, you can
use `xev` or `wev` to find that information.
If you want to bind by a keycode, you can just input it in the KEY position,
e.g.:
2022-09-24 16:03:37 +02:00
```ini
2022-09-24 15:32:40 +02:00
bind=SUPER,28,exec,amongus
```
Will bind <key>SUPER</key> + <key>T</key>. (<key>T</key> is keycode 28.) - You
can also use `xev` or `wev` to find keycodes.
2022-10-20 22:54:34 +02:00
# Misc
2022-09-24 15:32:40 +02:00
2022-10-20 22:54:34 +02:00
## Unbind
2022-10-19 15:22:42 +02:00
2022-09-24 15:32:40 +02:00
You can also unbind with `unbind`, e.g.:
2022-09-24 16:03:37 +02:00
```ini
2022-09-24 15:32:40 +02:00
unbind=SUPER,O
```
May be useful for dynamic keybindings with `hyprctl`.
2022-10-19 15:22:42 +02:00
```sh
hyprctl keyword unbind SUPER,O
```
2022-10-20 22:54:34 +02:00
## Mouse buttons
2022-10-19 15:22:42 +02:00
2022-09-24 15:32:40 +02:00
You can also bind mouse buttons, by prefacing the mouse keycode with `mouse:`,
for example:
2022-09-24 16:03:37 +02:00
```ini
2022-09-24 15:32:40 +02:00
bind=SUPER,mouse:272,exec,amongus
```
will bind it to <key>SUPER</key> + <key>LMB</key>.
2022-10-20 22:54:34 +02:00
## Only modkeys
2022-10-19 15:22:42 +02:00
2022-09-24 15:32:40 +02:00
For binding only modkeys, you need to use the TARGET modmask (with the
activating mod) and the `r` flag, e.g.:
2022-09-24 16:03:37 +02:00
```ini
2022-09-24 15:32:40 +02:00
bindr=SUPERALT,Alt_L,exec,amongus
```
2022-10-20 22:54:34 +02:00
## Mouse wheel
2022-10-19 15:22:42 +02:00
2022-09-24 15:32:40 +02:00
You can also bind the mouse wheel with `mouse_up` and `mouse_down`:
2022-10-19 15:22:42 +02:00
2022-09-24 16:03:37 +02:00
```ini
2022-09-24 15:32:40 +02:00
bind=SUPER,mouse_down,workspace,e-1
```
2022-10-19 15:22:42 +02:00
2022-09-24 15:32:40 +02:00
(control the reset time with `binds:scroll_event_delay`)
2022-10-20 22:54:34 +02:00
## Switches
2022-10-19 15:22:42 +02:00
2022-10-04 21:11:56 +02:00
Useful for binding e.g. the lid close/open event:
2022-10-19 15:22:42 +02:00
2022-10-20 17:48:30 +02:00
```ini
2022-10-04 21:11:56 +02:00
bindl=,switch:[switch name],exec,swaylock
```
2022-10-19 15:22:42 +02:00
2022-10-04 21:11:56 +02:00
check out your switches in `hyprctl devices`.
2022-10-20 22:54:34 +02:00
# Bind flags
2022-09-24 15:32:40 +02:00
2022-10-19 18:14:08 +02:00
`bind` supports flags in this format:
2022-09-24 15:32:40 +02:00
2022-09-24 16:03:37 +02:00
```ini
2022-09-24 15:32:40 +02:00
bind[flags]=...
```
e.g.:
2022-09-24 16:03:37 +02:00
```ini
2022-09-24 15:32:40 +02:00
bindrl=MOD,KEY,exec,amongus
```
2022-10-19 18:14:08 +02:00
Flags:
2022-09-24 15:32:40 +02:00
2022-09-24 16:03:37 +02:00
```ini
2022-10-23 00:58:34 +02:00
l -> locked, aka. works also when an an input inhibitor (e.g. a lockscreen) is active
2022-09-24 15:32:40 +02:00
r -> release, will trigger on release of a key
e -> repeat, will repeat when held.
m -> mouse, see below
```
2022-10-19 18:14:08 +02:00
Example Usage:
```ini
2022-10-19 18:18:53 +02:00
# Example volume button that allows press and hold
2022-10-20 17:48:30 +02:00
binde=, XF86AudioRaiseVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+
2022-10-19 18:18:53 +02:00
2022-10-20 22:14:52 +02:00
# Example volume button that will activate even while an input inhibitor is active
bindl=, XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-
2022-10-23 01:11:53 +02:00
# Start wofi opens wofi on first press, closes it on second
bindr=SUPER, SUPER_L, exec, pkill wofi || wofi
2022-10-19 18:18:53 +02:00
# See Mouse Binds section for bindm usage
2022-10-19 18:14:08 +02:00
```
2022-10-20 22:54:34 +02:00
# Mouse Binds
2022-10-19 15:22:42 +02:00
2022-09-24 15:32:40 +02:00
Mouse binds are binds that heavily rely on a mouse, usually its movement.
They will have one less arg, and look for example like this:
2022-10-19 18:14:08 +02:00
```ini
2022-09-24 15:32:40 +02:00
bindm=ALT,mouse:272,movewindow
```
this will create a bind with <key>ALT</key> + <key>LMB</key> to move the window
with your mouse.
2022-10-19 15:22:42 +02:00
_Available mouse binds_:
2022-09-24 15:32:40 +02:00
| Name | Description |
| -----|------------ |
2022-10-19 15:22:42 +02:00
| movewindow | moves the active window |
2022-09-24 15:32:40 +02:00
| resizewindow | resizes the active window |
2022-10-19 15:22:42 +02:00
_Common mouse buttons' codes:_
2022-10-19 18:14:08 +02:00
```txt
2022-09-24 15:32:40 +02:00
LMB -> 272
RMB -> 273
```
2022-10-19 15:22:42 +02:00
_for more, you can of course use `wev` to check._
2022-09-24 15:32:40 +02:00
{{< hint type=tip >}}
Mouse binds, despite their name, behave like normal binds. You are free to use
whatever keys / mods you please. When held, the mouse function will be activated.
{{< /hint >}}
2022-10-20 22:54:34 +02:00
# Binding mods
2022-09-24 15:32:40 +02:00
You can bind a mod alone like this:
2022-09-24 16:03:37 +02:00
```ini
2022-09-24 15:32:40 +02:00
bindr=ALT,Alt_L,exec,amongus
```
2022-10-20 22:54:34 +02:00
# Global Keybinds
2022-10-19 15:22:42 +02:00
2022-09-24 15:32:40 +02:00
Yes, you heard this right, Hyprland does support global keybinds for ALL apps,
including OBS, Discord, Firefox, etc.
2022-10-19 15:22:42 +02:00
See the [`pass` dispatcher](./Dispatchers/#dispatchers) for keybinds.
2022-09-24 15:32:40 +02:00
2022-10-23 00:58:34 +02:00
Let's take OBS as an example: the "Start/Stop Recording" keybind is set to
<key>SUPER</key> + <key>F10</key>, and you want to make it work globally.
2022-09-24 15:32:40 +02:00
2022-10-23 00:58:34 +02:00
Simply add
2022-10-19 15:22:42 +02:00
2022-09-24 16:03:37 +02:00
```ini
2022-09-24 15:32:40 +02:00
bind = SUPER,F10,pass,^(com\.obsproject\.Studio)$
```
2022-10-19 15:22:42 +02:00
2022-09-24 15:32:40 +02:00
to your config and you're done.
`pass` will pass the PRESS and RELEASE events by itself, no need for a `bindr`.
This also means that push-to-talk will work flawlessly with one pass, e.g.:
2022-09-24 16:03:37 +02:00
```ini
2022-09-24 15:32:40 +02:00
bind=,mouse:276,pass,^(TeamSpeak 3)$
```
Will pass MOUSE5 to TeamSpeak3.
{{< hint type=important >}}
XWayland is a bit wonky. Make sure that what you're passing is a "global Xorg
keybind", otherwise passing from a different XWayland app may not work.
It works flawlessly with all native Wayland applications though.
2022-10-19 15:22:42 +02:00
_Side note_: **OBS** on Wayland really dislikes keybinds with modifiers. If
2022-09-24 15:32:40 +02:00
they don't work, try removing mods and binding them to e.g. <key>F1</key>.
Combining this with a submap should yield neat and usable results.
{{< /hint >}}
2022-10-20 22:54:34 +02:00
# Submaps
2022-09-24 15:32:40 +02:00
If you want keybind submaps, for example if you press <key>ALT</key> +
<key>R</key>, you can enter a "resize" mode, resize with arrow keys, and leave
with escape, do it like this:
2022-09-24 16:03:37 +02:00
```ini
2022-10-18 17:08:17 +02:00
# will switch to a submap called resize
bind=ALT,R,submap,resize
2022-09-24 15:32:40 +02:00
2022-10-18 17:08:17 +02:00
# will start a submap called "resize"
submap=resize
2022-09-24 15:32:40 +02:00
2022-10-18 17:08:17 +02:00
# sets repeatable binds for resizing the active window
2022-09-24 15:32:40 +02:00
binde=,right,resizeactive,10 0
binde=,left,resizeactive,-10 0
binde=,up,resizeactive,0 -10
binde=,down,resizeactive,0 10
2022-10-18 17:08:17 +02:00
# use reset to go back to the global submap
2022-10-19 15:22:42 +02:00
bind=,escape,submap,reset
2022-09-24 15:32:40 +02:00
2022-10-18 17:08:17 +02:00
# will reset the submap, meaning end the current one and return to the global one
submap=reset
2022-09-24 15:32:40 +02:00
# keybinds further down will be global again...
```
**IMPORTANT:** do not forget a keybind to reset the keymap while inside it! (In
this case, `escape`)
If you get stuck inside a keymap, you can use `hyprctl dispatch submap reset` to
go back. If you do not have a terminal open, tough luck buddy. You have been warned.
2022-10-18 17:08:17 +02:00
You can also set the same keybind to perform multiple actions, such as resize
and close the submap, like so:
```ini
bind=ALT,R,submap,resize
submap=resize
bind=,right,resizeactive,10 0
bind=,right,submap,reset
# ...
submap=reset
```
This works because the binds are executed in the order they appear, and
assigning multiple actions per bind is possible.