Last active
May 17, 2025 00:56
-
-
Save ChristopherA/8d3f94d66b196b1c078fd43210ced2c3 to your computer and use it in GitHub Desktop.
Linux Keyboard Mapping for Legacy MacBooks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Linux Keyboard Remapping on Legacy MacBooks | |
> TO BE TESTED: on Ubuntu 22.04 LTS & Tails 5.x (with Dotfiles persistence). | |
How to get a MacBook’s keyboard behaving correctly under Linux—and make those settings survive reboots (especially in Tails). | |
## Debian/Ubuntu-based Distros | |
1. **Reconfigure the keyboard package** | |
```bash | |
sudo dpkg-reconfigure keyboard-configuration | |
``` | |
- **Model:** Apple Inc. Apple Keyboard | |
- **Layout:** English (US) | |
- **Alt/Win:** Swap Alt and Win | |
- **CapsLock:** Make Caps Lock an additional Ctrl | |
2. **Apply immediately** | |
```bash | |
sudo systemctl restart keyboard-setup.service | |
sudo udevadm trigger --subsystem-match=input --action=change | |
``` | |
3. **Permanent config** (`/etc/default/keyboard`) | |
```ini | |
XKBMODEL="apple" | |
XKBLAYOUT="us" | |
XKBVARIANT="" | |
XKBOPTIONS="altwin:swap_lalt_lwin,ctrl:nocaps" | |
``` | |
--- | |
## Persisting in Tails | |
By default, Tails boots a fresh, read-only system every time. To keep your keyboard tweaks across reboots: | |
1. **Enable “Dotfiles” persistence** in the Tails Persistent Storage wizard. | |
2. **Copy config into persistence** | |
```bash | |
mkdir -p ~/Persistent/etc | |
sudo cp /etc/default/keyboard ~/Persistent/etc/keyboard | |
``` | |
3. **Create startup script** in persistence | |
```bash | |
mkdir -p ~/Persistent/bin | |
cat << 'EOF' > ~/Persistent/bin/apply-keyboard.sh | |
#!/usr/bin/env bash | |
cp ~/Persistent/etc/keyboard /etc/default/keyboard | |
systemctl restart keyboard-setup.service | |
setxkbmap -model apple -layout us -option altwin:swap_lalt_lwin,ctrl:nocaps | |
EOF | |
chmod +x ~/Persistent/bin/apply-keyboard.sh | |
``` | |
4. **Autostart the script** | |
```bash | |
mkdir -p ~/.config/autostart | |
cat << 'EOF' > ~/.config/autostart/apply-keyboard.desktop | |
[Desktop Entry] | |
Type=Application | |
Name=Restore MacBook Keys | |
Exec=/home/amnesia/Persistent/bin/apply-keyboard.sh | |
X-GNOME-Autostart-enabled=true | |
EOF | |
``` | |
## Testing | |
1. Reboot into your Linux distro or Tails with persistence. | |
2. Open a terminal and press CapsLock → Ctrl and Alt → ⌘ to confirm the remaps. | |
3. If all works, your keyboard will now “just work” on every boot—even on stateless Tails sessions. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment