Skip to content

Instantly share code, notes, and snippets.

@agingorange
Forked from zw963/add_capslock_ctrl.sh
Created August 4, 2022 07:21
Show Gist options
  • Save agingorange/3a49cf0f1670e90f62894a8206b67e03 to your computer and use it in GitHub Desktop.
Save agingorange/3a49cf0f1670e90f62894a8206b67e03 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment