LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-26-2021, 08:14 PM   #1
Johng
Member
 
Registered: Feb 2002
Location: NZ
Distribution: Mint Suse
Posts: 362

Rep: Reputation: 30
simple script two commands to connect bluetooth keyboard


How would I issue two commands to connect a bluetooth keyboard.

When I issue the first command in a terminal: bluetoothctl

I get: [Bluetooth Keyboard]#

waiting for the next command.

Using the terminal I can enter the second command: connect xx:xx:xx:xx:xx:xx

where xx:xx:xx:xx:xx:xx is a valid mac address

My problem is I have not found a way to "script" the two commands.
 
Old 08-26-2021, 09:14 PM   #2
elnetotaca
LQ Newbie
 
Registered: Jan 2011
Posts: 16

Rep: Reputation: 0
Code:
#!/usr/bin/zsh

coproc bluetoothctl
echo -e 'agent on\nconnect F0:13:C3:4B:84:E9\nexit' >&p
output=$(cat <&p)
echo $output

Last edited by elnetotaca; 08-26-2021 at 09:15 PM.
 
Old 08-27-2021, 12:27 AM   #3
Johng
Member
 
Registered: Feb 2002
Location: NZ
Distribution: Mint Suse
Posts: 362

Original Poster
Rep: Reputation: 30
Thank you elnetotac

That was the answer I needed
 
Old 08-27-2021, 01:36 AM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,854

Rep: Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692
my bluetooth keyboard connects automatically (just need to switch on), I do not need to issue any command.
 
1 members found this post helpful.
Old 08-29-2021, 12:03 AM   #5
Johng
Member
 
Registered: Feb 2002
Location: NZ
Distribution: Mint Suse
Posts: 362

Original Poster
Rep: Reputation: 30
Using blueman command line to connect keyboard

My bluetooth keyboard does not connect automatically.

If I use the Blueman gui with mouse: Refresh Services/Setup/Proceed Without Pairing/Forward/Input Service/Forward, it connects.

Using a terminal I get:
Code:
bt-device --list
Added devices:
Bluetooth Keyboard (1E:A0:91:00:08:C7)
Code:
bt-device --connect=1E:A0:91:00:08:C7
Connecting to: 1E:A0:91:00:08:C7
Agent registered
Agent released
Done
but it does not connected.
I am having trouble comprehending the blueman man page.

What commands do I need to issue to connect (un-paired), and how would I create a script to run with only one mouse click??
 
Old 08-29-2021, 05:26 AM   #6
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,854

Rep: Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692
duplicate of https://www.linuxquestions.org/quest...ard-4175699758
And the answer was accepted. What's going on now?

Last edited by pan64; 08-29-2021 at 05:28 AM.
 
Old 08-29-2021, 03:36 PM   #7
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_12{.0|.1}
Posts: 5,715
Blog Entries: 11

Rep: Reputation: 3747Reputation: 3747Reputation: 3747Reputation: 3747Reputation: 3747Reputation: 3747Reputation: 3747Reputation: 3747Reputation: 3747Reputation: 3747Reputation: 3747
Please post your thread once and in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. Your two threads on this topic have been merged to help others follow the full context of the discussion.
 
Old 08-29-2021, 05:36 PM   #8
Johng
Member
 
Registered: Feb 2002
Location: NZ
Distribution: Mint Suse
Posts: 362

Original Poster
Rep: Reputation: 30
pan64
Quote:
duplicate of https://www.linuxquestions.org/quest...ard-4175699758
And the answer was accepted. What's going on now
The original question/answer related to a Suse 15.2 install

The second question referred to a Mint 17 install, a new issue? I understood different issues should not contaminate a thread.

The answer to the original question is not working with Mint 17 because:
Code:
echo -e 'connect 1E:A0:91:00:08:C7' | bluetoothctl
bluetoothctl: command not found
bluez and python-bluez are installed
Code:
sudo apt-get install bluetoothctl
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package bluetoothctl
I am reminded of Mark Twain quote:
Quote:
All you need in this life is ignorance and confidence, and then success is sure.
 
Old 08-30-2021, 01:46 AM   #9
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,854

Rep: Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692
I guess you forgot to mention that is another host, another OS. Or probably I missed something. But never mind, your [second] problem can be solved here as well.


Actually I would try to upgrade mint 17 to 20 first. bluetoothctl is available on mint 20 (I think). But unfortunately I have no mint 17 so that makes a bit difficult (for me).
 
Old 08-30-2021, 05:27 PM   #10
Johng
Member
 
Registered: Feb 2002
Location: NZ
Distribution: Mint Suse
Posts: 362

Original Poster
Rep: Reputation: 30
pan64
Quote:
Actually I would try to upgrade mint 17 to 20 first. bluetoothctl is available on mint 20 (I think). But unfortunately I have no mint 17 so that makes a bit difficult (for me).
Thank you. Upgrading Mint is one solution. I multi boot different Linux OS for various reasons, with a common keyboard. Technically and practically, I would like to know how to connect the keyboard with a script and mouse click in Mint 17.
 
Old 08-31-2021, 01:33 AM   #11
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,854

Rep: Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692Reputation: 5692
Quote:
Originally Posted by Johng View Post
pan64
Thank you. Upgrading Mint is one solution. I multi boot different Linux OS for various reasons, with a common keyboard. Technically and practically, I would like to know how to connect the keyboard with a script and mouse click in Mint 17.
That should have been explained in the first post. Anyway, mint 17 is over and you will hardly find even packages for that. (that's why you won't be able to install bluez-tools - probably).
You may find a working mirror for mint 17 - if I remember well that was posted somewhere here, at LQ.
this may help:
https://unix.stackexchange.com/quest...op-having-to-p
or this:
https://unix.stackexchange.com/quest...e-via-terminal
 
Old 09-04-2021, 12:52 AM   #12
Johng
Member
 
Registered: Feb 2002
Location: NZ
Distribution: Mint Suse
Posts: 362

Original Poster
Rep: Reputation: 30
Turns out the answer I was looking for to connect a bluetooth keyboard to Mint 17 was very simple:
Code:
bt-input -c xx:xx:xx:xx:xx:xx
Suggestions to upgrade to a more recent operating system avoid answering the question posed.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Bluetooth Stopped Working "Unknown Bluetooth Controller in /etc/bluetooth/main.conf" PasBern Linux - Hardware 5 06-15-2021 10:39 AM
Issue with Bluetooth Keyboard - in two different distros KYJazzyJeff Linux - Hardware 6 08-30-2020 08:28 AM
Simple Bluetooth Keyboard How-To (Logitech K810 or others) IsaacKuo LinuxQuestions.org Member Success Stories 0 09-01-2017 09:41 AM
[SOLVED] bluetooth dongle + bluetooth speaker but no sound on the bluetooth speaker vonbiber Slackware 4 05-11-2017 09:53 AM
one cpu ,two monitor, two keyboard, two mice..any help?? jeevanism Linux - Networking 9 01-04-2011 08:14 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration