Skip to content

Instantly share code, notes, and snippets.

@zw963
Last active May 17, 2021
Embed
What would you like to do?
A script which change Capslock to Ctrl, and change rightAlt to Capslock for GNOME + Wayland for Arch linux.
#! /bin/bash
if ! fgrep -qs 'ctrl:new_ctrl = +new_ctrl(new_ctrl)' /usr/share/X11/xkb/rules/evdev; then
sudo sed -i.bak '/ctrl:nocaps[[:blank:]]*=[[:blank:]]*+ctrl(nocaps)/a\
ctrl:new_ctrl = +new_ctrl(new_ctrl)
' /usr/share/X11/xkb/rules/evdev
fi
cat <<'HEREDOC' |sudo tee /usr/share/X11/xkb/symbols/new_ctrl
partial modifier_keys
xkb_symbols "new_ctrl" {
replace key <CAPS> { [ Control_L ] };
modifier_map Control { <CAPS>, <LCTL> };
replace key <RALT> { [ Caps_Lock ] };
modifier_map Lock { <RALT> };
};
HEREDOC
gsettings set org.gnome.desktop.input-sources xkb-options "['ctrl:new_ctrl']"
# for to disable this run
# gsettings reset org.gnome.desktop.input-sources xkb-options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment