console.systems

How to pair a Low Energy (LE) Bluetooth device in dual boot with Windows & Linux

Thursday, September 18, 2014

Those who dualboot know the pain of re-pairing your keyboard or mouse everytime you boot to a different OS. In this tutorial I will show how to pair a LE Bluetooth mouse in both Windows 8 and Debian simultaneously.

First pair the device in Debian, then reboot in Windows and pair the device there too. Yes, this will reset the paring in Debian, just carry on. Now we need to access the pairing keys in Windows. Download psexec.exe and open a command prompt with Administrator rights.

> cd Downloads
> psexec.exe -s -i regedit /e C:\BTKeys.reg HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\BTHPORT\Parameters\Keys

The keys should be now exported to C:\BTKeys.reg. You should get something like:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\BTHPORT\Parameters\Keys\7512a3185b2c\84abd4a25ee1]
"LTK"=hex:6c,54,ee,80,40,47,6c,cb,fc,8e,f3,f1,c6,b2,04,9e
"KeyLength"=dword:00000000
"ERand"=hex(b):1e,12,aa,37,39,cc,af,34
"EDIV"=dword:00003549
"CSRK"=hex:38,d7,aa,c1,42,06,31,25,12,b8,5a,6d,c3,90,98,f2

7512a3185b2c is the MAC address of the Bluetooth adapter, which can also be written in standard format as 75:12:A3:18:5B:2C. 84abd4a25ee1 is the mouse address that was assigned during the pairing. We will need those numbers in the next steps.

Now boot again to Debian. The mouse wont paired automatically, because it is now assigned to a different address and with different keys. Let's fix it.

$ cd /var/lib/bluetooth/75:12:A3:18:5B:2C/
$ ls
cache 84:AB:D4:A2:5F:E1 settings

If you look closely, the mouse address is not the same as in Windows. In my case only the fifth group is different. We need the device addresses to match, so rename the file.

$ mv 84:AB:D4:A2:{5F,5E}:E1
$ cd 84:AB:D4:A2:5E:E1/
$ ls
attributes gatt info

Now open the info file for editing and update the keys values. The relation between Windows and Bluez keys format is as follows:

At the end you should get this.

[LocalSignatureKey]
Key=38D7AAC14206312512B85A6DC39098F2

[LongTermKey]
Key=6C54EE8040476CCBFC8EF3F1C6B2049E
Authenticated=0
EncSize=0
EDiv=13641
Rand=3796477557015712286

Save the changes and reboot. From now on Debian and Windows will connect the mouse automatically. Awesome!

P.S. Mygod was nice to turn the instructions into a Python script, try it out.

Force Qt apps to use the currently selected Gnome 3 icon theme

Wednesday, February 26, 2014

Gconf, Dconf, Gsettings too many settings storages for Gnome. Although the latest Gnome 3 uses GSettings only, Qt 4.x still relies on Gconf from Gnome 2.x. So changing the icon theme in Gnome 3 doesn't affect Qt apps. What you need is to copy the theme name from Gsettings to GConf via this command:

$ gconftool-2 --type=string --set "/desktop/gnome/interface/icon_theme" `gsettings get org.gnome.desktop.interface icon-theme | tr -d "'"`

and restart the Qt app.

How to paste from PRIMARY selection buffer via keyboard shortcut

Monday, February 17, 2014

In your desktop environment of choice, go to keyboard shortcuts setting and create a new shortcut with the command:

$ sh -c 'xsel | xvkbd -file - 2>/dev/null'

and set the desired key combination.

Using Focusrite Scarlett 18i6 in Linux, Part II

Thursday, August 8, 2013

Earlier I posted how to patch ALSA for Scarlett. Apparently it didn't work for everyone.

Didn't work quite well for me either. Every time I put my computer to sleep, after resume Scarlett lose the connection and there was nothing I could do to bring it back, except rebooting the computer. I got so tired of it that I even switched to internal sound card on my motherboard.

Recently I found another way that some may find suitable too. Digital inputs! That's right, if you're okay to use Scarlett for playback only and you value the sound quality, digital inputs is the way to go. Scarlett has two options in fact, ADAT via TOSLINK and S/PDIF via RCA.

Luckily my motherboard is equipped with S/PDIF as well, TOSLINK and internal S/PDIF connector. Some motherboards may have ready S/PSID RCA output on rear panel. At least I had to spend 30 min with soldering iron to get a bracket like this:

Boot to Windows and enable S/PDIF inputs in Scarlett MixControl panel, if they are not enabled for some reason yet. Scarlett will remember the settings, so no need to do it again. Enjoy!

Expanding wildcards with qmake

Tuesday, March 26, 2013

I was always wondering why doing something like this never worked

SOURCES += *.cpp
SOURCES -= excluded.cpp

excluded.cpp always stayed in SOURCES. The thing is that when you add a new value to the list, it's just a string. Thus using wildcard in files names is nothing more but an asteriks character. And therefore using -= operator will only remove exact strings. But today I found another undocumented function I've been looking for years!

$$files(glob) — Returns a list of files which match the specified glob pattern.

So now I can do

SOURCES += $$files(*.cpp)
SOURCES -= excluded.cpp

and it actually works.

<- Newer Posts Older Posts ->