Skip to content

Instantly share code, notes, and snippets.

@zw963
Last active August 8, 2023 12:40
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save zw963/e8156358b2029c4f5a6f0d57fb9f6143 to your computer and use it in GitHub Desktop.
Save zw963/e8156358b2029c4f5a6f0d57fb9f6143 to your computer and use it in GitHub Desktop.
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
@ivanstepanovftw
Copy link

dconf write /org/gnome/desktop/input-sources/xkb-options "['grp:caps_toggle']"

@zw963
Copy link
Author

zw963 commented Feb 25, 2023

dconf write /org/gnome/desktop/input-sources/xkb-options "['grp:caps_toggle']"

Does this remap any key back to capslock?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment