Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Bluetooth keyboard on boot?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
dspahn
Guru
Guru


Joined: 22 Jun 2006
Posts: 360

PostPosted: Sun Oct 14, 2018 2:00 pm    Post subject: Bluetooth keyboard on boot? Reply with quote

Just finished a fresh Gentoo system, running systemd, gnome 3 is coming soon. I have a Logitech k480 that I need available for typing my password at a command shell. It is a Bluetooth keyboard. I can connect it and pair it manually using Bluetoothctl. Does anyone know how to make it pair automatically at boot so i can use it to log in to a shell?
Thanks!
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


Joined: 30 Aug 2008
Posts: 1654
Location: United Kingdom

PostPosted: Mon Oct 15, 2018 6:48 am    Post subject: Reply with quote

I don't have a Bluetooth keyboard to try this out, but I wonder if you could create a unit file (I'll call it /etc/systemd/system/pairkbd.service) that would run a Bash script containing the bluetoothctl commands you are currently entering manually.

Code:
[Unit]
Description=Pair Bluetooth keyboard at startup
After=multi-user.target bluetooth.service

[Service]
Type=idle
ExecStart=/usr/bin/pairkbd.sh

[Install]
WantedBy=multi-user.target

Code:
# systemctl enable pairkbd.service


The Bash script /usr/bin/pairkbd.sh would contain the bluetooothctl commands to pair the keyboard.

Would that do it?
_________________
Clevo W230SS: amd64 OpenRC elogind nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64 OpenRC elogind xf86-video-ati. Dual boot Win 7 Pro 64-bit.
KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
dspahn
Guru
Guru


Joined: 22 Jun 2006
Posts: 360

PostPosted: Mon Oct 15, 2018 12:36 pm    Post subject: It would, but... Reply with quote

I found a second problem... If I go into bluetoothctl and run
Quote:
power on
connect \t
quit


I get a line item showing the device is connected. I press a key and it says it is disconnected and then I press another key and it says it is connected again, and o on and so forth. The only way to avoid those messages is to put the keyboard in pairing mode, and go through the process of pairing... sort of tough to do before logging in! Obviously, the script will not work until this problem is resolved. By the way, I did find out some information about scripting these commands- you probably already know how, but for the edification of anyone else who may read this thread in the future, here is how to pass the commands from Bash to bluetoothctl:
Note the \n for newline:

Code:
echo -e 'power on\nconnect \t \nquit' | bluetoothctl


Any idea what I need to do to keep the pairing from boot to boot? It is a Logitech K480.

Thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum