Skip to content

Instantly share code, notes, and snippets.

@johnmarcampbell
Last active October 15, 2023 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save johnmarcampbell/95104e759610295a34211892c44d4f6a to your computer and use it in GitHub Desktop.
Save johnmarcampbell/95104e759610295a34211892c44d4f6a to your computer and use it in GitHub Desktop.
Create systemd service to remap caps lock to ctrl on boot
  1. Create the following three files:

/etc/systemd/system/caps-to-ctrl.service

[Service]
ExecStart=/usr/local/bin/caps-to-ctrl.sh

[Install]
WantedBy=default.target

/usr/local/bin/caps-to-ctrl.sh

#!/bin/bash
setxkbmap -option caps:ctrl_modifier

/lib/systemd/system-sleep/caps-to-ctrl

#!/bin/bash

case "$1" in 
    post)
        setxkbmap -option caps:ctrl_modifier;;
esac
  1. Set appropriate permissions and install service
chmod 744 /usr/local/bin/caps-to-ctrl.sh
chmod 664 /etc/systemd/system/caps-to-ctrl.service
chmod 755 /usr/lib/systemd/system-sleep/caps-to-ctrl
systemctl daemon-reload
systemctl enable caps-to-ctrl.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment