Difference between revisions of "Apple wireless keyboard on Linux"

From Organic Design wiki
(Interesting article about making a util to communicate with the Logitech K750 keyboard)
(blootoothctl)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
{{legacy}}
 +
 +
{{info|These days you will probably have more luck with [https://www.makeuseof.com/manage-bluetooth-linux-with-bluetoothctl/ bluetoothctl] instead.}}
 +
 
[[Image:AppleWirelessKeyboard.jpg|300px|right]]
 
[[Image:AppleWirelessKeyboard.jpg|300px|right]]
 
The new Apple wireless keyboards are a really nice looking and robust design, but unfortunately, Many people are having trouble using them under Linux.
 
The new Apple wireless keyboards are a really nice looking and robust design, but unfortunately, Many people are having trouble using them under Linux.
Line 7: Line 11:
  
 
First, find the MAC address of your device, as follows:
 
First, find the MAC address of your device, as follows:
{{code|<pre>hcitool scan</pre>}}
+
<source>
 +
hcitool scan
 +
</source>
  
  
 
This will yield something like the following output:
 
This will yield something like the following output:
{{code|<pre>
+
<source>
00:1D:D8:93:90:3D      Microsoft Bluetooth Notebook Mouse 5000
+
00:1D:D8:93:90:3D      Microsoft Bluetooth Notebook Mouse 5000
 
  00:1E:52:FC:4A:8E      Apple Wireless Keyboard
 
  00:1E:52:FC:4A:8E      Apple Wireless Keyboard
</pre>}}
+
</source>
  
  
 
Next, turn on the keyboard, and establish a connection as follows:
 
Next, turn on the keyboard, and establish a connection as follows:
{{code|<pre>hidd --connect 00:1E:52:FC:4A:8E</pre>}}
+
<source>
 +
hidd --connect 00:1E:52:FC:4A:8E
 +
</source>
  
  
Line 32: Line 40:
  
 
The change which we can make is to make the ''eject'' key into ''delete'' since Linux users have no use for eject.You can use ''xev'' to find keycodes by pressing keys, and use ''xmodmap -pke'' to list current key assignments. The keycode for the ''eject'' key on the Apple keyboards is ''204'', so we can map it to eject as follows:
 
The change which we can make is to make the ''eject'' key into ''delete'' since Linux users have no use for eject.You can use ''xev'' to find keycodes by pressing keys, and use ''xmodmap -pke'' to list current key assignments. The keycode for the ''eject'' key on the Apple keyboards is ''204'', so we can map it to eject as follows:
{{code|<pre>xmodmap -e "keycode 204 = Delete"</pre>}}
+
<source>
 +
xmodmap -e "keycode 204 = Delete"
 +
</source>
  
  
 
Another one I added was to make the ''f12'' key to the left of ''eject'' into an ''insert'' key as follows:
 
Another one I added was to make the ''f12'' key to the left of ''eject'' into an ''insert'' key as follows:
{{code|<pre>xmodmap -e "keycode 176 = Insert"</pre>}}
+
<source>
 +
xmodmap -e "keycode 176 = Insert"
 +
</source>
  
 
== See also ==
 
== See also ==
 +
*[[Brazilian keyboard settings]]
 
*[http://julien.danjou.info/blog/2012/logitech-k750-linux-support Interesting article about making a util to communicate with the Logitech K750 keyboard]
 
*[http://julien.danjou.info/blog/2012/logitech-k750-linux-support Interesting article about making a util to communicate with the Logitech K750 keyboard]
 
[[Category:Linux]][[Category:Hardware]]
 
[[Category:Linux]][[Category:Hardware]]

Latest revision as of 22:12, 24 December 2022

Legacy.svg Legacy: This article describes a concept that has been superseded in the course of ongoing development on the Organic Design wiki. Please do not develop this any further or base work on this concept, this is only useful for a historic record of work done. You may find a link to the currently used concept or function in this article, if not you can contact the author to find out what has taken the place of this legacy item.


Info.svg These days you will probably have more luck with bluetoothctl instead.


AppleWirelessKeyboard.jpg

The new Apple wireless keyboards are a really nice looking and robust design, but unfortunately, Many people are having trouble using them under Linux.

The main problem is that it times out and people assume that the problem is something to do with the Linux Bluetooth layer. But actually the problem is very easily solved - the keyboard requires a pin number to be established before it will allow the device to connect and bond.

Also, I find that there can be problems connecting to some devices using the GNOME applet by in the system try, so these instructions create the initial connection from a root terminal instead.

First, find the MAC address of your device, as follows:

hcitool scan


This will yield something like the following output:

00:1D:D8:93:90:3D      Microsoft Bluetooth Notebook Mouse 5000
 00:1E:52:FC:4A:8E      Apple Wireless Keyboard


Next, turn on the keyboard, and establish a connection as follows:

hidd --connect 00:1E:52:FC:4A:8E


This is where it would normally time out if left to its own devices, but actually all is well and the keyboard is waiting for you to enter a four digit PIN number such as 0000 into the Apple keyboard followed by the enter key. When you hit enter, a dialog box will come up allowing you to enter the matching PIN (using your currently working keyboard) which will then complete the connection and bonding process.

After this procedure, the keyboard should be listed in the connected and bonded devices list and will automatically be present after rebooting or whenever the keyboard is powered up.

Remapping keys

The Apple wireless keyboard is very compact, but to achieve its small foot print, some often used keys are missing, such as the page up/down, home/end and delete keys. These are emulated by using the fn pseudo-modifier key at the bottom left in combination with the cursor keys (and fn + backspace emulates the delete key). This solution is ok, but I'd like to make a couple of changes for more transparent use with Linux, one change can be done easily, the other can't be done at all.

The one we can't do is to swap the positions of fn and ctrl. Most windows and linux users are used to the control key being at the very bottom right and a function key being next inward not the other way round. But unfortunately the fn key is usually a pseudo-modifier key and has no key code because it doesn't exist as far as the software is concerned - its operation is determined by the keyboard hardware.

Actually I think this is wrong I think it's done in the kernel not the hardware, cos showkeys gives a result when pressing the fn key.

The change which we can make is to make the eject key into delete since Linux users have no use for eject.You can use xev to find keycodes by pressing keys, and use xmodmap -pke to list current key assignments. The keycode for the eject key on the Apple keyboards is 204, so we can map it to eject as follows:

xmodmap -e "keycode 204 = Delete"


Another one I added was to make the f12 key to the left of eject into an insert key as follows:

xmodmap -e "keycode 176 = Insert"

See also