Hyprland keybinding configuration syntax is not for humans.
I made a little script so you can write keybinding config with short and intuitive syntax.
The script will write the transpiled config into hyprland.conf
Based on the SXHKD / SWHKD keybinding syntax, with useful extension (bind flags)
Example:
# program launcher
alt + { _, super} + space
rofi -show {drun, run} -dpi 200 -show-icons
alt + bracket{left,right}
hyprctl dispatch workspace {r-1, r+1}
alt + shift + bracket{left,right}
hyprctl dispatch hy3:movetoworkspace {r-1, r+1}, follow
# focus or send to the given desktop
super + {_, shift} + {1-9,0}
hyprctl dispatch {workspace, hy3:movetoworkspace} {1-9,10}
# resize windows
( repeat )
super + ctrl + {h,j,k,l}
hyprctl dispatch resizeactive {-20 0, 0 20, 0 -20, 20 0}Transpiled Result config (hyprland.conf)
# >>> HOTKEY CONFIG TRANSPILED SECTION >>>
bind = alt, space, exec, rofi -show drun -dpi 200 -show-icons
bind = alt super, space, exec, rofi -show run -dpi 200 -show-icons
bind = alt, bracketleft, workspace, r-1
bind = alt, bracketright, workspace, r+1
bind = alt shift, bracketleft, hy3:movetoworkspace, r-1, follow
bind = alt shift, bracketright, hy3:movetoworkspace, r+1, follow
bind = super, 1, workspace, 1
bind = super, 2, workspace, 2
bind = super, 3, workspace, 3
bind = super, 4, workspace, 4
bind = super, 5, workspace, 5
bind = super, 6, workspace, 6
bind = super, 7, workspace, 7
bind = super, 8, workspace, 8
bind = super, 9, workspace, 9
bind = super, 0, workspace, 10
bind = super shift, 1, hy3:movetoworkspace, 1
bind = super shift, 2, hy3:movetoworkspace, 2
bind = super shift, 3, hy3:movetoworkspace, 3
bind = super shift, 4, hy3:movetoworkspace, 4
bind = super shift, 5, hy3:movetoworkspace, 5
bind = super shift, 6, hy3:movetoworkspace, 6
bind = super shift, 7, hy3:movetoworkspace, 7
bind = super shift, 8, hy3:movetoworkspace, 8
bind = super shift, 9, hy3:movetoworkspace, 9
bind = super shift, 0, hy3:movetoworkspace, 10
binde = super ctrl, h, resizeactive, -20 0
binde = super ctrl, j, resizeactive, 0 20
binde = super ctrl, k, resizeactive, 0 -20
binde = super ctrl, l, resizeactive, 20 0
# <<< HOTKEY CONFIG TRANSPILED SECTION <<<The transpiled binding config will be inserted between
# >>> HOTKEY CONFIG TRANSPILED SECTION >>>
and
# <<< HOTKEY CONFIG TRANSPILED SECTION <<<
in the hyprland.conf.
Specifying Flags
In addition to the normal SXHKD syntax, you can also specify flags supported by hyprland:
### Flags:
# l -> locked, will also work when an input inhibitor (e.g. a lockscreen) is active.
# r -> release, will trigger on release of a key.
# o -> long-press, will trigger on long press of a key.
# e -> repeat, will repeat when held.
# n -> non-consuming, key/mouse events will be passed to the active window in addition to triggering the dispatcher.
# m -> mouse, see below.
# t -> transparent, cannot be shadowed by other binds.
# i -> ignore mods, will ignore modifiers.
# s -> separate, will arbitrarily combine keys between each mod/key, see [Keysym combos](#keysym-combos) above.
# d -> has description, will allow you to write a description for your bind.
# p -> bypasses the app's requests to inhibit keybinds.
####
You can place ( flag1, flag2, flag3... ) right before the keybinding line.
You can either use full keywords (e.g. repeat) or abbreviated (e.g. e)
- Install bun.js
- feature-rich, lightweight, fast
- doesn't hurt to install it. Do it.
- add the following in the
hyprland.conf:
# >>> HOTKEY CONFIG TRANSPILED SECTION >>>
# <<< HOTKEY CONFIG TRANSPILED SECTION <<<
- Copy and paste the
hotkey_transpile.tsin the same directory ashyprland.conf- You might also want to copy-paste
tsconfig.jsonif you'll edit the script.
- You might also want to copy-paste
- Create
hotkeys.confin the same directory - Customize, and run
./hotkey_transpile.ts