maggioni.xyz/_site/linux/2016/07/07/get-a-bluetooth-keyboard-wo...

197 lines
10 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Get a Bluetooth keyboard work with Arch Linux</title>
<meta name="description" content="Ive recently got a Rapoo E6100. This is a minimal and space saving Bluetooth 3.0 keyboard. If you pair it with Windows 10, it will remain paired after reboo...">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css">
<link rel="stylesheet" href="/css/main.css">
<link href='https://fonts.googleapis.com/css?family=Hammersmith+One' rel='stylesheet' type='text/css'>
<link rel="canonical" href="http://praticamentetilde.github.io/linux/2016/07/07/get-a-bluetooth-keyboard-work-with-arch.html">
<link rel="alternate" type="application/rss+xml" title="Ramblings of an archer archer" href="http://praticamentetilde.github.io/feed.xml">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<script src="https://rawgit.com/snaptortoise/konami-js/master/konami.js"></script>
<!-- Favicon -->
<link rel="apple-touch-icon" sizes="57x57" href="/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/manifest.json">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="/ms-icon-144x144.png">
</head>
<body>
<header class="header">
<section class="head">
<h2 class="title">Ramblings of an archer archer</h2>
<p>Things which an Arch Linux user that also owns an recurve bow can write.
</p>
</section>
<nav class="navbar">
<div class="container">
<ul class="navbar-list">
<li class="navbar-item">
<a href="/">home</a>
</li>
<li class="navbar-item">
<a href="/about/">About</a>
</li>
<li class="navbar-item">
<a href="http://www.burarco.it">My archery club</a>
</li>
<li class="navbar-item">
<a href="/feed.xml">RSS</a>
</li>
</ul>
</div>
</nav>
</header>
<main class="container">
<article class="post" itemscope itemtype="http://schema.org/BlogPosting">
<header class="post-header">
<h2 class="post-title" itemprop="name headline">Get a Bluetooth keyboard work with Arch Linux</h2>
<p class="post-meta"><time datetime="2016-07-07T14:49:18+02:00" itemprop="datePublished">Jul 7, 2016</time></p>
</header>
<div class="post-content" itemprop="articleBody">
<p>Ive recently got a Rapoo E6100. This is a minimal and space saving Bluetooth 3.0 keyboard. If you pair it with Windows 10, it will remain paired after reboot, giving the possibility to use it since the login screen. After installing the Bluetooth stack on my Arch via the <code class="highlighter-rouge">bluez</code> and <code class="highlighter-rouge">bluez-utils</code> packages I thought the pairing process would be as simple as Windows if I used the KDE GUI menus for Bluetooth management. Thats not true. The keyboard, once paired, will reconnect automatically just after <code class="highlighter-rouge">plasmashell</code> loaded, leaving me without keyboard during the SDDM login screen and, of course, during a non-graphical session.</p>
<p>As usual, ive searched help in the ArchWiki, founding <a href="https://wiki.archlinux.org/index.php/Bluetooth_keyboard">this</a> article. With that, ive succesfully reconnected my Bluetooth keyboard using the <code class="highlighter-rouge">bluetoothctl</code> utility. The next step was configuring the service for auto connection during boot. Ive created the <code class="highlighter-rouge">btkbd.conf</code> and the <code class="highlighter-rouge">btkbd.service</code> files, enabling the last one with systemd. Lets give a look to the service file:</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><table style="border-spacing: 0"><tbody><tr><td class="gutter gl" style="text-align: right"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19</pre></td><td class="code"><pre><span class="o">[</span>Unit]
<span class="nv">Description</span><span class="o">=</span>systemd Unit to automatically start a Bluetooth keyboard
<span class="nv">Documentation</span><span class="o">=</span>https://wiki.archlinux.org/index.php/Bluetooth_Keyboard
<span class="nv">Requires</span><span class="o">=</span>dbus-org.bluez.service
<span class="nv">After</span><span class="o">=</span>dbus-org.bluez.service
<span class="nv">ConditionPathExists</span><span class="o">=</span>/etc/btkbd.conf
<span class="nv">ConditionPathExists</span><span class="o">=</span>/usr/bin/hcitool
<span class="nv">ConditionPathExists</span><span class="o">=</span>/usr/bin/hciconfig
<span class="o">[</span>Service]
<span class="nv">Type</span><span class="o">=</span>oneshot
<span class="nv">EnvironmentFile</span><span class="o">=</span>/etc/btkbd.conf
<span class="nv">ExecStart</span><span class="o">=</span>/usr/bin/hciconfig <span class="k">${</span><span class="nv">HCIDEVICE</span><span class="k">}</span> up
<span class="c"># ignore errors on connect, spurious problems with bt?</span>
<span class="c"># so start next command with -</span>
<span class="nv">ExecStart</span><span class="o">=</span>-/usr/bin/hcitool cc <span class="k">${</span><span class="nv">BTKBDMAC</span><span class="k">}</span>
<span class="o">[</span>Install]
<span class="nv">WantedBy</span><span class="o">=</span>multi-user.target<span class="w">
</span></pre></td></tr></tbody></table></code></pre></figure>
<p>Line 13 enables the Bluetooth dongle, and line 16 connects it to the keyboard we gave the mac address in <code class="highlighter-rouge">/etc/btkbd.conf</code>. This should work flawlessly, right? Of course it doesnt. The service starts before the <code class="highlighter-rouge">dbus-org.bluez.service</code> is loaded and fails. However, if the service is started manually after login the Bluetooth keyboard works. After hours of trying figuring out what was wrong Ive almost asked for a return on Amazon! The last attempt I made was with sddm disabled and involved built from scratch service:</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><table style="border-spacing: 0"><tbody><tr><td class="gutter gl" style="text-align: right"><pre class="lineno">1
2
3
4
5
6
7
8
9
10</pre></td><td class="code"><pre><span class="o">[</span>Unit]
<span class="nv">Description</span><span class="o">=</span>systemd Unit to automatically start a Bluetooth keyboard
<span class="o">[</span>Service]
<span class="nv">Type</span><span class="o">=</span>oneshot
<span class="nv">ExecStart</span><span class="o">=</span>/bin/hciconfig hci0 up
<span class="nv">ExecStart</span><span class="o">=</span>/bin/hcitool cc 00:11:22:33:44:55
<span class="o">[</span>Install]
<span class="nv">WantedBy</span><span class="o">=</span>bluetooth.target<span class="w">
</span></pre></td></tr></tbody></table></code></pre></figure>
<p>This incredibly worked. I think the problem was that <code class="highlighter-rouge">multi-user.target</code> that needs to be reached earlier than <code class="highlighter-rouge">bluetooth.target</code>. I got rid of all the tidiness of the ArchWiki solution just to be sure that was not the problem, but I think you can use all of that just correcting <code class="highlighter-rouge">WantedBy=</code>. Currently I havent an ArchWiki account nor a forum one, but as soon as Ill register Ill correct the article.</p>
<p>Let me know in the comments if this solution is well made or if its just a bodge.
Last thing: I discovered that my Bluetooth dongle is CSR 8510 A10 based so expect some ramblings about <a href="http://www.0xf8.org/2014/02/the-crux-of-finding-a-hid-proxy-capable-usb-bluetooth-adapter/">hid proxy</a>.</p>
</div>
</article>
<div id="disqus_thread"></div>
<script>
/**
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables
*/
/*
var disqus_config = function () {
this.page.url = PAGE_URL; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
*/
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = '//ramblingsofanarcherarcher.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
</main>
<footer class="site-footer">
<div class="icons">
<a class="icon" href="https://github.com/praticamentetilde"><i class="fa fa-reddit"></i></a>
<a class="icon" href="https://www.reddit.com/user/praticamentetilde"><i class="fa fa-github"></i></a>
</div>
<h6 class="author">Claudio Maggioni 2016</h6>
</footer>
<script>
var easter_egg = new Konami();
easter_egg.load("https://www.youtube.com/watch?v=URTcCh6QVwM");
</script>
</body>
</html>