maggioni.xyz/_site/feed.xml
2018-11-14 20:23:19 +00:00

339 lines
22 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>maggioni.xyz</title>
<description>Eat polenta and do not counter-aim!
</description>
<link>https://maggioni.xyz/</link>
<atom:link href="https://maggioni.xyz/feed.xml" rel="self" type="application/rss+xml"/>
<pubDate>Wed, 14 Nov 2018 20:22:48 +0000</pubDate>
<lastBuildDate>Wed, 14 Nov 2018 20:22:48 +0000</lastBuildDate>
<generator>Jekyll v3.8.5</generator>
<item>
<title>How to rickroll people that try to run &quot;rm -rf&quot; on your system</title>
<description>&lt;strong&gt;
WARNING: The method showed here could not prevent the actual execution of &quot;rm -rf&quot; if the &quot;UNIX vandal&quot; is clever enough. Proceed at your own risk, and make backups!
&lt;/strong&gt;
&lt;p&gt;
I like Rick Astley late 80's songs, and you can see them here in my Spotify:
&lt;/p&gt;
&lt;p&gt;
&lt;img
src=&quot;/images/spotify_rickastley.png&quot;
alt=&quot;My Spotify with a bunch of Rick Astley songs&quot;&gt;
&lt;/p&gt;
&lt;p&gt;
I like rickrolling people too, especially if they are trying to delete my entire
&lt;code&gt;/home&lt;/code&gt; directory or, even worse, &lt;code&gt;/&lt;/code&gt;. Since I learned
how to use the &lt;code&gt;alias&lt;/code&gt; built-in, I wanted a way to prevent that
random people tinkering with my laptop (that I may forgot to lock) could
delete potentially important stuff, just for fun or boredom.
&lt;/p&gt;
&lt;p&gt;
The method that I will show will lock any &lt;code&gt;rm&lt;/code&gt; command runned in
both recursive and force mode, so &lt;code&gt;rm -rf&lt;/code&gt;, &lt;code&gt;rm -f -r&lt;/code&gt;
and &lt;code&gt;rm -r --force&lt;/code&gt; are all blocked, even if they are runned with
&lt;code&gt;sudo&lt;/code&gt;. I am going to alias the rm command in
&lt;code&gt;/etc/profile&lt;/code&gt;, &lt;code&gt;/etc/bash.bashrc&lt;/code&gt; and in
&lt;code&gt;/etc/zsh/zshrc&lt;/code&gt; (I am a zsh user) so that the rickroll will be
possible from all users, even root and the ones with a brand new
&lt;code&gt;.bashrc&lt;/code&gt; or &lt;code&gt;.zshrc&lt;/code&gt;. Here is the code I appended to
those files:
&lt;/p&gt;
&lt;p&gt;
&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;alias rm&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/bin/rmAlias
&lt;span class=&quot;nb&quot;&gt;alias sudo&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'sudo '&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# this enables aliases in sudo, see http://askubuntu.com/questions/22037/aliases-not-available-when-using-sudo&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;
Since &lt;code&gt;alias&lt;/code&gt; is not able to control the flags of the aliases (see
&lt;a href=&quot;http://apple.stackexchange.com/questions/50963/how-do-i-add-a-flag-to-an-alias&quot;&gt;here&lt;/a&gt;, we are going to redirect each call of &lt;code&gt;rm&lt;/code&gt; to
&lt;code&gt;/bin/rmAlias&lt;/code&gt;, that would run the command if it is safe. I did
not use a function because it is a bit tricky to make that work with
&lt;code&gt;sudo&lt;/code&gt;. So, let's see the code I put in &lt;code&gt;rmAlias&lt;/code&gt;:
&lt;/p&gt;
&lt;p&gt;
&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;#! /bin/bash&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Rickroll whoever tries to desert this system, even root.&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# To achieve this, set the appropriate aliases even in /etc/profile and similars.&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Video played when rickrolling&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;ROLLVIDEO&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/opt/anti-rm/serious-video.mkv &lt;span class=&quot;c&quot;&gt;# it's just Never Gonna Give You Up on my system, but be free to customize this!&lt;/span&gt;
rickroll&lt;span class=&quot;o&quot;&gt;(){&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Never gonna desert this system...&quot;&lt;/span&gt;
xdg-open &lt;span class=&quot;nv&quot;&gt;$ROLLVIDEO&lt;/span&gt; 2&amp;gt;&amp;amp;1 &amp;amp;
&lt;span class=&quot;nb&quot;&gt;exit &lt;/span&gt;0
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;while &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;getopts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;:rf-&quot;&lt;/span&gt; opt&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Prevent '--force' to be detected as -r and -f&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$opt&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;-&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then
&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;OPTIND&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$OPTIND&lt;/span&gt;+1
&lt;span class=&quot;k&quot;&gt;continue
fi
if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$opt&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;r&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$opt&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;f&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then
if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$tmp&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then
&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;tmp&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$opt&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;continue
elif&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$tmp&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$opt&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then
&lt;/span&gt;rickroll
&lt;span class=&quot;k&quot;&gt;fi
fi
done
for &lt;/span&gt;var &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$@&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;do
if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[[&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$var&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;--force&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$tmp&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;r&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then
&lt;/span&gt;rickroll
&lt;span class=&quot;k&quot;&gt;fi
done&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# If it's safe, just run rm&lt;/span&gt;
/bin/rm &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$@&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;exit&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$?&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;
It may look messy to a &lt;em&gt;UNIX&lt;/em&gt; guy more experienced than me, but it
works. The &lt;code&gt;getopts&lt;/code&gt; built-in sees if both the &lt;code&gt;-r&lt;/code&gt; and
the &lt;code&gt;-f&lt;/code&gt; flags are used and, if so, it starts
&lt;code&gt;rickroll()&lt;/code&gt;, which opens with &lt;code&gt;xdg-open&lt;/code&gt; that amazing
clip from &lt;em&gt;RickAstleyVEVO&lt;/em&gt;. From line 30 and below, the script checks
if the &lt;code&gt;--force&lt;/code&gt; flag is used instead of &lt;code&gt;-f&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;
Let's give execution permissions to the script we have just created:
&lt;/p&gt;
&lt;p&gt;
&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;# chmod +x /bin/rmAlias&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;
Restart your shell, and enjoy. If you want to test safely, I suggest trying
to run &lt;code&gt;rm -rf&lt;/code&gt; with no folders or a nonexistant one, since this
script stops even these commands.
&lt;/p&gt;
&lt;p&gt;
If you want even more security, you can rename this script to
&lt;code&gt;/bin/rm&lt;/code&gt; and move the original one in some other place, getting rid of all the aliases. I prefer the solution above because it's tidier: you haven't to move anything. In fact, this could be just an AUR package...
&lt;/p&gt;
</description>
<pubDate>Thu, 28 Jul 2016 14:00:00 +0000</pubDate>
<link>https://maggioni.xyz/linux/2016/07/28/how-to-rickroll-people-launching-rm-rf-on-your-system.html</link>
<guid isPermaLink="true">https://maggioni.xyz/linux/2016/07/28/how-to-rickroll-people-launching-rm-rf-on-your-system.html</guid>
<category>linux</category>
</item>
<item>
<title>Installing Gentoo on a Lenovo ThinkPad X60s</title>
<description>&lt;p&gt;
Currently, my only laptop is a
&lt;a href=&quot;http://www.thinkwiki.org/wiki/Category:X60s&quot;&gt;IBM/Lenovo ThinkPad
X60s&lt;/a&gt;, a top line &lt;em&gt;ultrabook&lt;/em&gt; from 2006 that features:
&lt;ul&gt;
&lt;li&gt;An Intel Core Duo L2400 dual core 32 bit CPU, clocked at 1.66 Ghz;&lt;/li&gt;
&lt;li&gt;2GB of RAM;&lt;/li&gt;
&lt;li&gt;60GB of SATA1 hard drive;&lt;/li&gt;
&lt;li&gt;Wifi, Bluetooth, trackpoint mouse only, 56k modem, and a decent set of
I/0 ports (including a CardBus slot!).&lt;/li&gt;
&lt;/ul&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img
src=&quot;/images/thinkpad1.jpg&quot;
alt=&quot;An image of the ThinkPad X60s&quot;&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img
src=&quot;/images/thinkpad2.jpg&quot;
alt=&quot;Another image of the ThinkPad X60s&quot;&gt;
&lt;/p&gt;
&lt;p&gt;
This machine had an installation on &lt;em&gt;Arch Linux&lt;/em&gt;, and I was using it
for school stuff. It runned smoothly &lt;em&gt;KDE5&lt;/em&gt;, &lt;em&gt;Atom&lt;/em&gt; (great
editor, I am using it to write this article), and it was usable even with
&lt;em&gt;PhpStorm&lt;/em&gt;. Pretty impressive for such an old thing, right?
&lt;/p&gt;
&lt;p&gt;
Since now I don't need this laptop every day I decided to give a try at Gentoo,
another rolling relase, DIY install distro. This was both a test of my
skills, my patience and the performances of the machine. For those of you
that don't know, Gentoo hasn't binary packages: imagine using Arch with just
a developer mantained AUR.
&lt;/p&gt;
&lt;p&gt;
I followed the &lt;a href=&quot;https://wiki.gentoo.org/wiki/Handbook:Main_Page&quot;&gt;
installation guide&lt;/a&gt; without any problem until I had to &lt;em&gt;emerge&lt;/em&gt;
and install 309 packets from my &lt;code&gt;@world&lt;/code&gt; set: it took 15 hours!
The compilation of &lt;code&gt;cmake&lt;/code&gt; crashed because of memory starvation,
and so I had to use a spare USB stick as swap (the root file system was not
resizable as it was JFS). After some research and a couple of seconds in
&lt;code&gt;top&lt;/code&gt; I discovered that
&lt;a href=&quot;https://en.wikipedia.org/wiki/Physical_Address_Extension&quot;&gt;PAE&lt;/a&gt;
was not implemented in the install disk kernel. &lt;strong&gt;TIP:&lt;/strong&gt; if you
want to use a nicer install enviroment, use the &lt;em&gt;Arch&lt;/em&gt; ISO. With
&lt;em&gt;Gentoo&lt;/em&gt;, the initialisation of the file system is made with a
&lt;a href=&quot;https://wiki.gentoo.org/wiki/Stage_tarball#Stage_3&quot;&gt;&lt;em&gt;stage 3
tarball&lt;/em&gt;&lt;/a&gt; and not by tools like
&lt;a href=&quot;https://wiki.archlinux.org/index.php/beginners'_guide#Install_the_base_packages&quot;&gt;
&lt;code&gt;pacstrap&lt;/code&gt;&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
I had another problem with &lt;code&gt;make menuconfig&lt;/code&gt;, the tool used to
specify what features add or remove in your compiled from source Linux kernel.
The &lt;code&gt;ncurses&lt;/code&gt; menu showed me 64bit options, even if the install
disk and the CPU were both 32 bit. If you have this issue too, you can set
the &lt;code&gt;ARCH&lt;/code&gt; variable by your own:
&lt;/p&gt;
&lt;p&gt;
&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;# make ARCH=i386 menuconfig&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# make ARCH=i386&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# make ARCH=i386 install&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;
At the end, I made it! I only have a base install, but i can show you
&lt;code&gt;screenfetch&lt;/code&gt;:
&lt;/p&gt;
&lt;p&gt;
&lt;img
src=&quot;/images/screenfetch.jpg&quot;
alt=&quot;The laptop running 'screenfetch'&quot;&gt;
&lt;/p&gt;
&lt;p&gt;
I have not installed &lt;em&gt;Gentoo&lt;/em&gt; in dual boot because I did not figure
out how to switch my bluetooth dongle in HID mode yet, so I can't select the
OS with &lt;code&gt;rEFInd&lt;/code&gt;. Hope this rambling was, if not useful, at least
entertaining!
&lt;/p&gt;
</description>
<pubDate>Tue, 12 Jul 2016 11:00:00 +0000</pubDate>
<link>https://maggioni.xyz/linux/2016/07/12/installing-gentoo-on-a-thinkpad-x60s.html</link>
<guid isPermaLink="true">https://maggioni.xyz/linux/2016/07/12/installing-gentoo-on-a-thinkpad-x60s.html</guid>
<category>linux</category>
</item>
<item>
<title>Get a Bluetooth keyboard work with Arch Linux</title>
<description>&lt;p&gt;
I've 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 &lt;code&gt;bluez&lt;/code&gt; and &lt;code&gt;bluez-utils&lt;/code&gt; packages I thought the pairing process would be as simple as Windows if I used the KDE GUI menus for Bluetooth management. That's not true. The keyboard, once paired, will reconnect automatically just after &lt;code&gt;plasmashell&lt;/code&gt; loaded, leaving me without keyboard during the SDDM login screen and, of course, during a non-graphical session.
&lt;/p&gt;
&lt;p&gt;
As usual, i've searched help in the ArchWiki, founding &lt;a href=&quot;https://wiki.archlinux.org/index.php/Bluetooth_keyboard&quot;&gt;this&lt;/a&gt; article. With that, i've succesfully reconnected my Bluetooth keyboard using the &lt;code&gt;bluetoothctl&lt;/code&gt; utility. The next step was configuring the service for auto connection during boot. I've created the &lt;code&gt;btkbd.conf&lt;/code&gt; and the &lt;code&gt;btkbd.service&lt;/code&gt; files, enabling the last one with systemd. Let's give a look to the service file:
&lt;/p&gt;
&lt;p&gt;
&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;Unit]
&lt;span class=&quot;nv&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;systemd Unit to automatically start a Bluetooth keyboard
&lt;span class=&quot;nv&quot;&gt;Documentation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;https://wiki.archlinux.org/index.php/Bluetooth_Keyboard
&lt;span class=&quot;nv&quot;&gt;Requires&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;dbus-org.bluez.service
&lt;span class=&quot;nv&quot;&gt;After&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;dbus-org.bluez.service
&lt;span class=&quot;nv&quot;&gt;ConditionPathExists&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/etc/btkbd.conf
&lt;span class=&quot;nv&quot;&gt;ConditionPathExists&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/usr/bin/hcitool
&lt;span class=&quot;nv&quot;&gt;ConditionPathExists&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/usr/bin/hciconfig
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;Service]
&lt;span class=&quot;nv&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;oneshot
&lt;span class=&quot;nv&quot;&gt;EnvironmentFile&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/etc/btkbd.conf
&lt;span class=&quot;nv&quot;&gt;ExecStart&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/usr/bin/hciconfig &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;HCIDEVICE&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; up
&lt;span class=&quot;c&quot;&gt;# ignore errors on connect, spurious problems with bt?&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# so start next command with -&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;ExecStart&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;-/usr/bin/hcitool cc &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;BTKBDMAC&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;Install]
&lt;span class=&quot;nv&quot;&gt;WantedBy&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;multi-user.target&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;
Line 13 enables the Bluetooth dongle, and line 16 connects it to the keyboard we gave the mac address in &lt;code&gt;/etc/btkbd.conf&lt;/code&gt;. This should work flawlessly, right? Of course it doesn't. The service starts before the &lt;code&gt;dbus-org.bluez.service&lt;/code&gt; 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 I've almost asked for a return on Amazon! The last attempt I made was with sddm disabled and involved built from scratch service:
&lt;/p&gt;
&lt;p&gt;
&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;Unit]
&lt;span class=&quot;nv&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;systemd Unit to automatically start a Bluetooth keyboard
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;Service]
&lt;span class=&quot;nv&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;oneshot
&lt;span class=&quot;nv&quot;&gt;ExecStart&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/bin/hciconfig hci0 up
&lt;span class=&quot;nv&quot;&gt;ExecStart&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/bin/hcitool cc 00:11:22:33:44:55
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;Install]
&lt;span class=&quot;nv&quot;&gt;WantedBy&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;bluetooth.target&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;
This incredibly worked. I think the problem was that &lt;code&gt;multi-user.target&lt;/code&gt; that needs to be reached earlier than &lt;code&gt;bluetooth.target&lt;/code&gt;. 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 &lt;code&gt;WantedBy=&lt;/code&gt;. Currently I haven't an ArchWiki account nor a forum one, but as soon as I'll register I'll correct the article.
&lt;/p&gt;
&lt;p&gt;
Last thing: I discovered that my Bluetooth dongle is CSR 8510 A10 based so expect some ramblings about &lt;a href=&quot;http://www.0xf8.org/2014/02/the-crux-of-finding-a-hid-proxy-capable-usb-bluetooth-adapter/&quot;&gt;hid proxy&lt;/a&gt;.
&lt;/p&gt;
</description>
<pubDate>Thu, 07 Jul 2016 12:49:18 +0000</pubDate>
<link>https://maggioni.xyz/linux/2016/07/07/get-a-bluetooth-keyboard-work-with-arch.html</link>
<guid isPermaLink="true">https://maggioni.xyz/linux/2016/07/07/get-a-bluetooth-keyboard-work-with-arch.html</guid>
<category>linux</category>
</item>
</channel>
</rss>