Niri doesn’t have a command to change its settings yet. However, as its config files are live reloaded, you can write to them programmatically and it will update immediately. Here’s my script to toggle the swapescape keyboard functionality that swaps Escape and CapsLock:
#!/bin/bash
if [ $(
grep -c ",caps:swapescape" ~/.config/niri/config.kdl
) -eq 1 ]; then
sed -i s/",caps:swapescape//" ~/.config/niri/config.kdl
else
sed -i "s/options \"grp:win_space_toggle/&,caps:swapescape/" ~/.config/niri/config.kdl
fi
I bind the script to a keyboard shortcut in niri config:
Mod+Shift+A { spawn "bash" "-c" "~/scripts/toggle_caps_esc_swap.sh"; }
I like to have the keys swapped, but some games act weirdly with it and use the actual Esc key, which also enables CapsLock in addition to showing some in-game menu. This way, I can quickly disable the swap when launching the game, and enable it after I’m done.
You must log in or # to comment.
