Skip to content

Instantly share code, notes, and snippets.

@codywilliamson
Last active November 3, 2025 04:59
Show Gist options
  • Select an option

  • Save codywilliamson/e161e5afb75b89e30c3ba5d061ee3260 to your computer and use it in GitHub Desktop.

Select an option

Save codywilliamson/e161e5afb75b89e30c3ba5d061ee3260 to your computer and use it in GitHub Desktop.
#!/bin/bash
# A script to install and configure keyd on Linux Mint (and other Ubuntu-based distros)
# to remap Caps Lock + IJKL to arrow keys, plus text editing keys.
#
# To run:
# 1. Save this as "install_keyd_arrows.sh"
# 2. chmod +x install_keyd_arrows.sh
# 3. sudo ./install_keyd_arrows.sh
# --- SAFETY CHECKS ---
# 1. Check for root
if [ "$EUID" -ne 0 ]; then
echo "Please run this script with sudo."
exit 1
fi
# 2. Check if keyd is already installed
if command -v keyd &> /dev/null; then
echo "keyd is already installed. Backing up existing config..."
# Backup existing config just in case
mv /etc/keyd/default.conf /etc/keyd/default.conf.bak_$(date +%F-%T)
else
# --- 1. INSTALL DEPENDENCIES ---
echo "Updating package lists..."
apt update
echo "Installing dependencies (git and build-essential)..."
apt install -y git build-essential
# --- 2. CLONE AND INSTALL KEYD ---
echo "Cloning keyd repository..."
# Clone to a temp directory
git clone https://github.com/rvaiya/keyd /tmp/keyd
cd /tmp/keyd
echo "Building and installing keyd..."
make && make install
echo "keyd installation complete."
fi
# --- 3. CREATE CONFIGURATION FILE ---
echo "Creating new keyd configuration at /etc/keyd/default.conf..."
# Use tee with a heredoc to write the config file as root
tee /etc/keyd/default.conf > /dev/null <<'EOF'
[ids]
*
[main]
# Make capslock a layer-switch key.
# When held, it activates the [nav] layer.
# When tapped, it does nothing.
capslock = layer(nav)
# --- Alternative: Tap for Caps, Hold for Layer ---
# If you still want tap-for-caps, comment the line above
# and uncomment this one:
# capslock = overload(nav, capslock)
[nav]
# This layer is active while capslock is held
#
# Arrow Keys
i = up
j = left
k = down
l = right
# Editing Keys
backspace = delete
, = home
. = end
EOF
# --- 4. ENABLE AND START THE SERVICE ---
echo "Enabling and starting the keyd service..."
systemctl enable --now keyd
echo "Reloading keyd configuration..."
keyd reload
# --- 5. CLEANUP ---
echo "Cleaning up temporary files..."
rm -rf /tmp/keyd
echo "All done! Your Caps Lock + IJKL keys (and more) should now be active."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment