Skip to content

dporkka/linux-keyboard-setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Linux macOS-like Keyboard Setup

A GNOME/Wayland keyboard configuration that makes a standard PC keyboard behave more like macOS: the physical Alt key (next to the spacebar, where macOS Cmd lives) becomes the primary modifier for app shortcuts, window management, and launcher access.

Why this layout?

On a Mac, your thumb rests on Cmd. Copy, paste, tab switching, app switching, and Spotlight all use Cmd. On a PC keyboard, Cmd does not exist, but Alt sits in the same ergonomic position. This setup swaps the internal meaning of Alt and Ctrl so that your thumb naturally controls the actions you use most.

Key benefits:

  • Ergonomics: Your strongest thumb controls copy/paste, tab switching, and app switching instead of your pinky on Ctrl.
  • Consistency across apps: Browsers, terminals, and editors already use Ctrl for shortcuts; after the swap, those shortcuts move to the macOS Cmd position.
  • Muscle memory: If you switch between a Mac and a Linux machine, the modifier placement stays the same.
  • Speed: Direct workspace switching (Super + 1..4) and a launcher under Alt + Space reduce hand travel to the mouse.
  • Caps Lock as additional Shift: The unused Caps Lock key sends Shift, adding an easier-to-reach Shift key under the left pinky. Both original Shift keys still work normally.

What changes

Modifier swap

  • Physical Alt → sends Ctrl
  • Physical Ctrl → sends Alt
  • Caps Lock → additional Shift (Left and Right Shift still work normally)

System shortcuts (physical Alt key)

Shortcut Action
Alt + Tab Window/app switcher
Alt + Shift + Tab Switch backward
`Alt + `` Cycle windows of the same app
`Alt + Shift + `` Same-app cycle backward
Alt + F4 Close window
Alt + F10 Maximize / unmaximize
Alt + F7 Move window
Alt + F8 Resize window
Alt + Space Open GNOME search / launcher

Application shortcuts (automatic with the swap)

Most apps already use Ctrl for these, so they move to the physical Alt key:

Shortcut Action
Alt + C / Alt + V / Alt + X Copy / paste / cut
Alt + Z / Alt + Shift + Z Undo / redo
Alt + T New tab
Alt + W Close tab
Alt + Shift + T Reopen closed tab
Alt + R Reload
Alt + F Find
Alt + 1..9 Switch to tab 1–9
Alt + [ / Alt + ] Previous / next tab (with keyd on Linux / AHK on WSL)

Custom launchers

Shortcut Action
Super + Return Open terminal (ptyxis)
Super + E Open editor (zed)
Super + B Open browser (firefox)
Super + Shift + S Interactive screenshot
Super + 1..4 Switch to workspace 1–4
Super + Shift + 1..4 Move window to workspace 1–4

Terminal tab switching

  • Ptyxis: remapped to Ctrl + 1..0, so Alt + 1..0 switches tabs. The default Ctrl + PageUp / Ctrl + PageDown shortcuts move to the previous / next tab; keyd (Linux) and the AHK script (WSL) translate Alt + [ / Alt + ] into those chords.
  • WezTerm: patch included (configs/wezterm-tab-switching.patch) that adds Ctrl + 1..9 tab switching plus Ctrl + [ / Ctrl + ] and Ctrl + PageUp / Ctrl + PageDown for previous / next tab.

Browser

  • Firefox: user.js makes Ctrl the primary accelerator, so Alt + 1..9 switches tabs and Alt + C/V copies/pastes.
  • Chromium / Chrome / Edge: already use Ctrl + 1..9 for tabs, so the swap makes Alt + 1..9 work immediately.
  • Previous / next tab (Alt + [ / Alt + ]): with keyd (Linux) or the AutoHotkey script (WSL) installed, these chords are translated into Ctrl + PageUp / Ctrl + PageDown, which Firefox and Chromium already use for previous / next tab.

Cross-platform previous / next tab

Physical Alt + [ / Alt + ] is translated into the standard Ctrl + PageUp / Ctrl + PageDown tab-switching chords so it works in Firefox, Chrome, Edge, WezTerm, and Windows Terminal.

Linux (Wayland or X11)

Install keyd and load the included config:

# Fedora
sudo dnf copr enable alternateved/keyd
sudo dnf install keyd

# Ubuntu 25.04+ / Debian 13+
sudo apt install keyd

# Arch
sudo pacman -S keyd

Then copy the config and start the daemon:

sudo install -Dm644 configs/keyd.conf /etc/keyd/default.conf
sudo systemctl enable --now keyd
sudo keyd reload

keyd runs below the display server, so the same config works on Wayland, X11, and even a Linux VT.

WSL / Windows

Run the AutoHotkey v2 script on the Windows host:

# From the windows/ directory, double-click keyboard-macos.ahk,
# or place a shortcut to it in your Startup folder.

The script now sends Ctrl + PageUp / Ctrl + PageDown when you press physical Alt + [ / Alt + ]. Add the windows/windows-terminal-shortcuts.json actions to Windows Terminal so the same chords switch WSL tabs.

Requirements

  • GNOME 40+ on Wayland or X11
  • gsettings and dconf
  • Firefox (if using the Firefox profile tweak)
  • ptyxis or wezterm (if using the terminal tab-switching tweaks)

The configuration was built on Fedora 44 Workstation (GNOME Classic on Wayland) and is fully Wayland-native.

Wayland compatibility

This setup does not use any X11-specific tools such as xmodmap, xbindkeys, xcape, or setxkbmap. Everything is configured through GNOME's gsettings/dconf and D-Bus interfaces, which work identically on both Wayland and X11 GNOME sessions.

  • The modifier swap (AltCtrl, Caps LockShift) is applied via org.gnome.desktop.input-sources xkb-options, which is honored by the Wayland compositor.
  • Custom shortcuts (Super+Return, Super+E, Alt+Space, etc.) are registered with GNOME's media-keys daemon.
  • Window management (Alt+Tab, Alt+F4) is handled by Mutter on both display servers.
  • The screenshot shortcut calls GNOME Shell directly over D-Bus, so it works on Wayland without X11 screenshot tools.

If you log out and choose a different GNOME session type (Classic, standard, Xorg, or Wayland), the same keyboard configuration will follow your user account.

Setup

1. Clone the repo

git clone https://github.com/dporkka/linux-keyboard-setup.git
cd linux-keyboard-setup

2. Run the apply script

./apply.sh

The script will:

  • Back up your current GNOME, IBus, and Ptyxis settings to ~/.local/share/linux-keyboard-setup-backups/
  • Load the GNOME keyboard and shortcut settings
  • Clear IBus triggers so Alt + Space opens GNOME search
  • Load the Ptyxis tab-switching configuration
  • Copy firefox-user.js to all detected Firefox profiles

3. Apply the WezTerm patch (optional)

cd ~/.config/wezterm
git apply /path/to/linux-keyboard-setup/configs/wezterm-tab-switching.patch

4. Restart

Log out and log back in. Firefox needs a restart as well for user.js to take effect.

Distribution notes

Fedora / RHEL / AlmaLinux

Everything should work out of the box. The script uses gsettings, dconf, and gdbus, all installed by default.

sudo dnf install gnome-tweaks  # optional, useful for visual shortcut inspection

Ubuntu / Pop!_OS

Install the required tools if they are missing:

sudo apt update
sudo apt install dconf-cli gnome-shell

Ubuntu-specific notes

  • Terminal: Ubuntu's default terminal is gnome-terminal, not ptyxis. The apply.sh script automatically detects the first available terminal (ptyxis, gnome-terminal, kgx, alacritty, wezterm) and updates the Super+Return launcher.
  • Editor: zed may not be installed on Ubuntu. The apply.sh script detects zed, code, gnome-text-editor, gedit, or nvim and updates the Super+E launcher accordingly.
  • Firefox snap: Ubuntu ships Firefox as a snap by default. Snap Firefox profiles live under ~/snap/firefox/common/.mozilla/firefox/. The apply.sh script copies user.js to that location in addition to the standard ~/.mozilla/firefox/ path.
  • Ubuntu Dock: Ubuntu uses the Ubuntu Dock extension, which may override some Super+number behavior. If Super+1..4 for workspaces does not behave as expected, open Settings → Keyboard → Keyboard Shortcuts → View and Customize Shortcuts → Navigation and check that no dock shortcuts conflict.
  • Pop Shell: If you use Pop!_OS with Pop Shell, review configs/gnome-wm-keybindings.dconf before applying, since Pop Shell adds its own tiling shortcuts that may overlap.
  • Wayland vs Xorg: Ubuntu 22.04+ defaults to Wayland but still supports Xorg at the login screen. This configuration works on both because it uses GNOME settings rather than X11 tools.

Debian

Install the required tools if they are missing:

sudo apt update
sudo apt install dconf-cli gnome-shell

Debian-specific notes

  • Terminal: Debian's default GNOME terminal is gnome-terminal. apply.sh will detect and use it automatically.
  • Editor: gedit or gnome-text-editor are the most common graphical editors on Debian. apply.sh detects zed, code, gnome-text-editor, gedit, or nvim.
  • Firefox: Debian ships Firefox as a native .deb package (or Firefox ESR in some releases). Profiles are at ~/.mozilla/firefox/. If you installed Firefox from a flatpak or snap, copy configs/firefox-user.js to the appropriate profile directory manually.
  • Stock GNOME: Debian uses a very close-to-stock GNOME session, so the default shortcuts in this repo should apply cleanly.
  • Wayland vs Xorg: Debian defaults to Wayland for GNOME when available, but Xorg is still an option at login. The configuration works on both.

Arch Linux / EndeavourOS / Manjaro

Install the required tools:

sudo pacman -S dconf gnome-shell gsettings-desktop-schemas

Arch-specific notes

  • Terminal: Arch does not ship a default terminal. Common choices are alacritty, wezterm, gnome-terminal, or kitty. apply.sh detects any of the supported terminals and updates the launcher.

  • Editor: zed and code may need to be installed from the AUR or official repositories. apply.sh falls back to gnome-text-editor, gedit, or nvim if those are present.

  • Firefox: The standard Arch package stores profiles at ~/.mozilla/firefox/. If you use the Flatpak, profiles are under ~/.var/org.mozilla.firefox/.mozilla/firefox/.

  • AUR packages: ptyxis and zed are often only available through the AUR. If you want the exact Fedora defaults, install them first; otherwise apply.sh will pick the next available terminal/editor.

  • Minimal GNOME installs: If you installed only gnome-shell without the full GNOME group, verify the required schemas exist:

    gsettings list-schemas | grep -E "wm.keybindings|media-keys"
  • Wayland vs Xorg: Arch GNOME defaults to Wayland but supports Xorg. The configuration works on both display servers.

Other desktop environments

This configuration targets GNOME. For KDE Plasma, Sway, or Hyprland you would need different tooling:

  • KDE Plasma: use kwriteconfig5 and System Settings → Shortcuts.
  • Sway / i3: configure in ~/.config/sway/config.
  • Hyprland: configure in ~/.config/hypr/hyprland.conf.

The core idea (swap Alt and Ctrl via XKB, then bind the system switcher to the new Ctrl position) translates to any environment, but the files here are GNOME-specific.

Windows / WSL

This repo also includes a Windows-compatible layer in the windows/ directory:

  • windows/keyboard-macos.ahk — AutoHotkey v2 script that remaps Alt+C/V/X, Alt+1..9, Caps Lock -> Shift, and Ctrl+Tab -> Alt+Tab.
  • windows/windows-terminal-shortcuts.json — Windows Terminal keybindings so Alt+1..9 switches WSL tabs.
  • windows/README.md — full Windows/WSL installation instructions.

Because WSL receives keyboard input from Windows, running the AutoHotkey script on the Windows host makes the same shortcuts work in WSL terminals and GUI apps. See windows/README.md for details.

Revert

Run the revert script to restore the backed-up settings, GNOME dock shortcuts, IBus triggers, Ptyxis defaults, and the WezTerm keys.lua from git:

./revert.sh

Then log out and back in.

Important caveats

  • Alt + Space requires Control + Space to be free. The apply script clears the IBus input-method triggers. If you type in multiple languages, re-enable IBus in Settings → Keyboard and pick a different launcher shortcut.
  • Super + 1..4 replaces the default GNOME dock app launchers. If you want those back, remove the workspace bindings or reassign them to different keys.
  • This setup assumes a US English layout (us). Other layouts may need adjusted XKB options.

Files in this repo

configs/
  gnome-input-sources.dconf       # xkb options: Alt/Ctrl swap, Caps Lock as additional Shift
  gnome-media-keys.dconf          # custom shortcuts (terminal, editor, browser, screenshot, search)
  gnome-wm-keybindings.dconf      # window manager shortcuts (switcher, close, maximize, etc.)
  gnome-shell-keybindings.dconf   # workspace and dock shortcuts
  ptyxis.dconf                    # terminal tab-switching config (numbered tabs)
  firefox-user.js                 # Firefox accelerator key tweak
  wezterm-tab-switching.patch     # WezTerm Ctrl+number / Ctrl+bracket / Ctrl+PageUp tab bindings
  keyd.conf                       # Linux keyd config for Alt+[ / Alt+] previous/next tab
windows/
  keyboard-macos.ahk              # AutoHotkey v2 script for Windows/WSL
  windows-terminal-shortcuts.json # Windows Terminal tab-switching keybindings
  README.md                       # Windows/WSL setup guide
apply.sh                          # Apply all settings (Linux)
revert.sh                         # Restore previous settings (Linux)

License

MIT — feel free to adapt this for your own setup.

About

Linux macOS-like Keyboard Setup A GNOME/Wayland keyboard configuration that makes a standard PC keyboard behave more like macOS: the physical Alt key (next to the spacebar, where macOS Cmd lives) becomes the primary modifier for app shortcuts, window management, and launcher access.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors