hyprland-wiki/pages/Configuring/Uncommon-tips-&-tricks.md
2024-05-21 12:01:26 +01:00

4.3 KiB

weight title
17 Uncommon tips & tricks

Switchable keyboard layouts

The easiest way to accomplish this is to set this using XKB settings, for example:

input {
    kb_layout = us,cz
    kb_variant = ,qwerty
    kb_options = grp:alt_shift_toggle
}

Variants are set per layout.

{{< callout >}}

The first layout defined in the input section will be the one used for binds by default.

For example: us,ua -> config binds would be e.g. SUPER, A, while on ua,us -> SUPER, Cyrillic_ef

You can change this behavior globally or per-device by setting resolve_binds_by_sym = 1. In that case, binds will activate when the symbol typed matches the symbol specified in the bind.

For example: if your layouts are us,fr and have a bind for SUPER, A you'd need to press the first letter on the second row while the us layout is active and the first letter on the first row while the fr layout is active.

{{< /callout >}}

You can also bind a key to execute hyprctl switchxkblayout for more keybind freedom. See Using hyprctl.

To find the valid layouts and kb_options, you can check out the /usr/share/X11/xkb/rules/base.lst. For example:

To get the layout name of a language:

grep -i 'persian' /usr/share/X11/xkb/rules/base.lst

To get the list of keyboard shortcuts you can put in the kb_options to toggle keyboard layouts:

grep 'grp:.*toggle' /usr/share/X11/xkb/rules/base.lst

Disabling keybinds with one master keybind

If you want to disable all keybinds with another keybind (make a keybind toggle of sorts) you can just use a submap with only a keybind to exit it.

bind=MOD,KEY,submap,clean
submap=clean
bind=MOD,KEY,submap,reset
submap=reset

Remap Caps-Lock to Ctrl

input {
    kb_options = ctrl:nocaps
}

Swap Caps-Lock and Escape

input {
    kb_options = caps:swapescape
}

Minimize windows using special workspaces

This approach uses special workspaces to mimic the "minimize window" function, by using a single keybind to toggle the minimized state. Note that one keybind can only handle one window.

bind = $mod, S, togglespecialworkspace, magic
bind = $mod, S, movetoworkspace, +0
bind = $mod, S, togglespecialworkspace, magic
bind = $mod, S, movetoworkspace, special:magic
bind = $mod, S, togglespecialworkspace, magic

Minimize Steam instead of killing

Steam will exit entirely when its last window is closed using the killactive dispatcher. To minimize Steam to tray, use the following script to close applications:

if [ "$(hyprctl activewindow -j | jq -r ".class")" = "Steam" ]; then
    xdotool getactivewindow windowunmap
else
    hyprctl dispatch killactive ""
fi

Shimeji

To use Shimeji programs like this, set the following rules:

windowrule=float, com-group_finity-mascot-Main
windowrule=noblur, com-group_finity-mascot-Main
windowrule=nofocus, com-group_finity-mascot-Main
windowrule=noshadow, com-group_finity-mascot-Main
windowrule=noborder, com-group_finity-mascot-Main

{{< callout type=info >}}

The app indicator probably won't show, so you'll have to killall -9 java to kill them.

{{< /callout >}}

Demo GIF of Spamton Shimeji

Toggle animations/blur/etc hotkey

For increased performance in games, or for less distractions at a keypress

  1. create file ~/.config/hypr/gamemode.sh && chmod +x ~/.config/hypr/gamemode.sh and add:
#!/usr/bin/env sh
HYPRGAMEMODE=$(hyprctl getoption animations:enabled | awk 'NR==1{print $2}')
if [ "$HYPRGAMEMODE" = 1 ] ; then
    hyprctl --batch "\
        keyword animations:enabled 0;\
        keyword decoration:drop_shadow 0;\
        keyword decoration:blur:enabled 0;\
        keyword general:gaps_in 0;\
        keyword general:gaps_out 0;\
        keyword general:border_size 1;\
        keyword decoration:rounding 0"
    exit
fi
hyprctl reload

Edit to your liking of course. If animations are enabled, it disables all the pretty stuff. Otherwise, the script reloads your config to grab your defaults.

  1. Add this to your hyprland.conf:
bind = WIN, F1, exec, ~/.config/hypr/gamemode.sh

The hotkey toggle will be WIN+F1, but you can change this to whatever you want.