如何在ThinkPad X1 Yoga上复刻苹果键盘Fn组合键导航功能?
Hey there, I totally get missing that Apple keyboard navigation convenience—let's get your ThinkPad set up to match it. Below are two reliable methods depending on whether you're using X11 or Wayland (most modern Linux desktops use Wayland these days, like the default GNOME setup on the X1 Yoga).
Method 1: For X11 Environments (e.g., Xfce, older GNOME)
We’ll use xmodmap to remap the key combinations directly:
Identify your keycodes
Open a terminal and runxev. A small window will pop up—focus it, then press each Fn+arrow key pair one by one. Look for lines likekeycode 113 (keysym 0xff50, Home)(your actual keycodes might differ). Jot down the keycode for each combination.Create an xmodmap config file
Open~/.Xmodmapin your favorite text editor (e.g.,nano ~/.Xmodmap) and add lines like this, replacing the placeholder keycodes with the ones you found:! Map Fn+Left to Home keycode 113 = Home NoSymbol Home ! Map Fn+Right to End keycode 114 = End NoSymbol End ! Map Fn+Up to Page Up keycode 111 = Prior NoSymbol Prior ! Map Fn+Down to Page Down keycode 116 = Next NoSymbol NextThe
NoSymbolentry handles modifier combinations, and repeating the target key ensures the mapping works with Shift (e.g., Shift+Fn+Left selects text to the start of the line).Apply and persist the mapping
Runxmodmap ~/.Xmodmapin the terminal to test it immediately. If it works, set it to run on startup:- Add
xmodmap ~/.Xmodmapto your desktop environment’s startup applications list. - If you use
startx, add that line to~/.xinitrc.
- Add
Method 2: For Wayland Environments (e.g., Modern GNOME)
Wayland doesn’t support xmodmap, so we’ll use ydotool (to simulate key presses) and sxhkd (to listen for key combinations) as a flexible workaround:
Install required tools
Open a terminal and install them with your package manager:# Debian/Ubuntu-based systems sudo apt install sxhkd ydotool # Fedora/RHEL-based systems sudo dnf install sxhkd ydotool # Arch-based systems sudo pacman -S sxhkd ydotoolCreate the sxhkd config
First, create the config directory if it doesn’t exist, then open the config file:mkdir -p ~/.config/sxhkd nano ~/.config/sxhkd/sxhkdrcAdd these lines (use
wev—Wayland’s event viewer—to find your Fn key’s actual name ifXF86LaunchAdoesn’t work):# Fn+Left → Home XF86LaunchA + Left ydotool key Home # Fn+Right → End XF86LaunchA + Right ydotool key End # Fn+Up → Page Up XF86LaunchA + Up ydotool key Page_Up # Fn+Down → Page Down XF86LaunchA + Down ydotool key Page_DownStart sxhkd on boot
Create a systemd user service to run sxhkd automatically:nano ~/.config/systemd/user/sxhkd.servicePaste this content:
[Unit] Description=Simple X hotkey daemon After=graphical-session.target [Service] ExecStart=/usr/bin/sxhkd Restart=always [Install] WantedBy=graphical-session.targetEnable and start the service:
systemctl --user enable sxhkd.service systemctl --user start sxhkd.service
Quick Test
After setting up either method, open a text editor (like Gedit or VS Code) and try pressing Fn+Left/Right/Up/Down—you should jump to the start/end of the line, or scroll up/down pages just like your old Apple keyboard.
内容的提问来源于stack exchange,提问作者Naftuli Kay




