个人工具

UbuntuHelp:AppleKeyboard

来自Ubuntu中文

跳转至: 导航, 搜索


Preface

Since Ubuntu 8.04 (Hardy Heron) the USB aluminium Apple Keyboard has not worked correctly. A change was added to the Ubuntu Linux kernel to make Apple MacBook keyboards gain additional functionality to their limited laptop style keyboard (Ubuntu bug #162083). Unfortunately this code change has some side effects for owners of the full size USB aluminium Apple Keyboard:

  • Function keys have media functions as default. The "fn" key must be pressed and held to access the F-key functionality (except F5 and F6, which are inverted in this respect). (Ubuntu bug #201711)
  • Two keys are swapped on international (non-US) keyboard with respect to the printing on the keycaps. (Ubuntu bug #214786)
  • Bug filed in the main kernel bugzilla http://bugzilla.kernel.org/show_bug.cgi?id=10818. Please help if you think that the kernel developers are wrong, assuming that the keyboard have to behave like under MacOS.

Default Behavior

This section describe the default behavior of every Apple keyboard.

Apple slim aluminium keyboard (0220)

AppleKeyboard?action=AttachFile&do=get&target=wired_1_20070813a.jpg

  • 'fn'+'Enter' -> Insert
  • 'fn'+'Backspace' -> Delete
  • 'fn'+'Up' -> PageUp
  • 'fn'+'Down' -> PageDown
  • 'fn'+'Left' -> Home
  • 'fn'+'Right' -> End
  • 'Clear' behave like 'NumLock'

(See #262408 as there is patch submit to map F13, F14 and F15 to PrintScreen, ScrollLock and Pause.)

Corrections

Change Function Key behavior

This section of the document describe how to change the behavior of 'fn' key to better match what user expect. (See #201711, #162083) Here a description of each behavior :

  • 0 = disabled : Disable the 'fn' key. Pressing 'fn'+'F8' will behave like you only press 'F8'
  • 1 = fkeyslast : Function keys are used as last key. Pressing 'F8' key will act as a special key. Pressing 'fn'+'F8' will behave like a F8.
  • 2 = fkeysfirst : Function keys are used as first key. Pressing 'F8' key will behave like a F8. Pressing 'fn'+'F8' will act as special key (play/pause).

Ubuntu 9.04 (Jaunty Jakalope)

Temporarily

This section describe how to change the behavior of 'fn' with immediate effect (Restarting will reset the configuration). Execute the following commands to change the fnmode parameters. See section above for a description of available value.

$ sudo bash
# echo 2 > /sys/module/hid_apple/parameters/fnmode
# exit
Permanently

This section describe how to change the behavior of 'fn' permanently. There is many way to proceed with this modification. Each sub section describe one way to permanently change the configuration.

With .conf file (Recommended)

1. Edit or create the file /etc/modprobe.d/hid_apple.conf, e.g.:

sudo gedit /etc/modprobe.d/hid_apple.conf

2. Add this line to the previously open file.

options hid_apple fnmode=2

3. Save the file and execute the following command to notify hid_apple module to reload it's configuration.

sudo update-initramfs -u

4. Reboot

With rc.local

1. Edit the /etc/rc.local file.

sudo gedit /etc/rc.local

2. Add this line near the end of the file, before the "exit" line:

echo 2 > /sys/module/hid_apple/parameters/fnmode

3. Reboot

With sysfs.conf

1. Edit the /etc/sysfs.conf file.

sudo gedit /etc/sysfs.conf

2. Add this lines to the end of the file.

module/hid_apple/parameters/fnmode = 2

3. Reboot

Ubuntu 8.10 (Intrepid Ibex)

Temporarily

With immediate effect, try

sudo bash
echo 2 > /sys/module/hid/parameters/pb_fnmode
exit
Permanently

1. Edit the file /etc/modprobe.d/options, e.g.:

sudo gedit /etc/modprobe.d/options

2. Add the line:

options hid pb_fnmode=2

3. Save the file and execute the following command:

sudo update-initramfs -u

4. Reboot

Alternatively, you can modify /etc/rc.local to similar effect.

  • Edit the /etc/rc.local file:
sudo gedit /etc/rc.local
  • Add this line to the end of the file:
echo 2 > /sys/module/hid/parameters/pb_fnmode

Alternatively, you can modify /etc/sysfs.conf to similar effect.

  • Edit the /etc/sysfs.conf file:
sudo gedit /etc/sysfs.conf
  • Add this lines to the end of the file:
module/hid/parameters/pb_fnmode = 2

Correcting the two swapped keys for international (non-US) keyboards

This section describe how to fix the issue related to the swapped key when using international keyboard. (See #214786)

Ubuntu 9.10 (Karmic Koala)

  • Edit your ./.xsession file:
gedit ./.xsession
  • Insert this line as the second line of the file (after the first line which is probably #!/bin/sh):
xmodmap -e 'keycode 49 = less greater less greater bar brokenbar bar' -e 'keycode 94 = dead_circumflex degree dead_circumflex degree U2032 U2033 U2032'

You will have to relogin or reboot. The <> and ^° key should now be in the correct position.

Ubuntu 9.04 (Jaunty Jakalope)

Need to confirm if the problem persist as there is modification done in the kernel to fix the problem.

Ubuntu 8.10 (Intrepid Ibex)

1. Open the 'System->Preferences->Keyboard' dialog 2. Choose the 'Layouts' tab 3. Press 'Layout Options...' 4. Navigate to 'Miscellaneous compatibility options' 5. Enable the option: Swap keycodes of two keys when Mac keyboards are misdetected by kernel.

Mapping keys (Insert, Alt, Cmd, etc.)

This section describe how to change the mapping of key to better match PC's keyboard. e.g.: Swap the Alt key and Command key. The idea is to make the keyboard work more like a normal PC keyboard.

Adding a Second Control key

The command/apple keys on macs are recognized as "Super" or "Windows" shift by default. To make the right command key a ctrl key, save this in ~/.Xmodmap file:

clear control
clear mod4

keycode 37 = Control_L
keycode 134 = Control_R
!### change 134 to 116 if using Ubuntu hardy, not 8.10 or later. ###
add control = Control_L Control_R

add mod4 = Super_L

Then run the command "xmodmap ~/.Xmodmap".

Ubuntu 8.10 (Intrepid Ibex) through 10.04 (Lucid Lynx)

Save the following in a file .Xmodmap in your home directory:

! Swap Alt and Cmd keys.
keycode 37 =	Control_L
keycode 133 =	Alt_L Meta_L
keycode 64 =	Super_L
keycode 108 =	Super_R
keycode 134 =	ISO_Level3_Shift Multi_key
keycode 105 =	Control_R	Multi_key
clear Shift
clear Lock
clear Control
clear Mod1
clear Mod2
clear Mod3
clear Mod4
clear Mod5
add    Shift   = Shift_L Shift_R
add    Lock    = Caps_Lock
add    Control = Control_L Control_R
add    Mod1    = Alt_L 0x007D
add    Mod2    = Num_Lock
add    Mod4    = Super_L Super_R
add    Mod5    = Mode_switch ISO_Level3_Shift ISO_Level3_Shift ISO_Level3_Shift

! Configure '=' key on numpad as '='.
keycode 0x7D =  equal

Load the configuration by executing a command similar to the following.

xmodmap ~/.Xmodmap

Note : Gnome will ask you if you want to load this configuration the next time you log in.

Ubuntu 8.04 (Hardy Heron)

This section describe how to change the mapping for Ubuntu 8.04 (Hardy Heron) with kernel >= 2.6.27. 1. Edit or create ~/.Xmodmap file with a content similar to the following.

! Configure F13 as Insert key
! F14 as PrintScr
| F15 as ScrollLock
! F16 as Pause/Break
keycode 182 = Insert
keycode 183  =  Print       Sys_Req
keycode 184  =  Scroll_Lock
keycode 93   =  Pause   Break

! Swap Alt and Command keys
keycode 0x25 =  Control_L
keycode 0x73 =  Alt_L       Meta_L
keycode 0x40 =  Super_L
keycode 0x71 =  Super_R
keycode 0x74 =  ISO_Level3_Shift    Multi_key
keycode 0x75 =  NoSymbol
keycode 0x6D =  Control_R   Multi_key
clear Shift
clear Lock
clear Control
clear Mod1
clear Mod2
clear Mod3
clear Mod4
clear Mod5
add    Shift   = Shift_L Shift_R
add    Lock    = Caps_Lock
add    Control = Control_L Control_R
add    Mod1    = Alt_L 0x007D
add    Mod2    = Num_Lock
add    Mod4    = Super_L Super_R
add    Mod5    = Mode_switch ISO_Level3_Shift ISO_Level3_Shift ISO_Level3_Shift

! Configure '=' key on numpad as '='.
keycode 0x9D =  equal

2. Load the configuration by executing a command similar to the following.

xmodmap ~/.Xmodmap

Note : The configuration should be load on next logon.

Belgian Macintosh Keyboard Layout

Take a look at https://help.ubuntu.com/community/Macbook_Air#head-5fd0bcf04cc7da0b5241950916bab5d58cdb84da in the Belgian Keyboard section

Postscript

These issues may also apply for the Bluetooth aluminium Apple Wireless Keyboard.