AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1170809
Accepted
Netmoon
Netmoon
Asked: 2019-09-05 05:11:07 +0800 CST2019-09-05 05:11:07 +0800 CST 2019-09-05 05:11:07 +0800 CST

如何让蓝牙扬声器在登录时自动连接?

  • 772

今天我在预装了 Windows 7 的戴尔 Latitude E6410i 上安装了 Ubuntu 18.04 x64 LTS。我使用蓝牙 4.2 和 A2DP V1.3、AVRCP V1.6、HFP V1.6 和 HSP V1.2 连接到我的新JBL Flip4 扬声器,并成功配对。

我想在登录时自动连接到扬声器;每次我登录到 Ubuntu 时它都应该连接,但没有。

经过研究,我在网上找到了一些建议(比如Autoconnect to a bluetooth speaker in Ubuntu 16.04rc.local ),但在我的系统中找不到。另外,我安装了bt-autoconnect 这没有帮助。

我应该如何着手解决这个问题?

sound bluetooth login 18.04 bluetooth-speaker
  • 2 2 个回答
  • 6077 Views

2 个回答

  • Voted
  1. Best Answer
    UnKNOWn
    2019-09-06T01:58:19+08:002019-09-06T01:58:19+08:00

    解决问题

    注意:使用我的 操作系统
    测试的以下程序:JBL Xtreme
    Ubuntu 18.04

    在您目前的情况下,您已经配对了您的 BT 设备,并且在启动时您的 BT 设备处于开启状态,

    登录后试试这个..

    1. 打开终端并运行bluetoothctl

    2. 输出将与此类似

    输出:

    pratap@i7-4770:~$ bluetoothctl
    [NEW] Controller xx:xx:xx:xx:xx:xx i7-4770 [default]
    [NEW] Device aa:bb:cc:dd:ee:ff JBL Xtreme
    [NEW] Device xx:xx:xx:xx:xx:xx HUAWEI P smart
    Agent registered
    [bluetooth]# 
    
    1. 在上述情况下,“JBL Xtreme”蓝牙设备已配对但尚未连接。所以要连接到此设备

    connect aa:bb:cc:dd:ee:ff按提示运行[bluetooth]#

    例子:

    [bluetooth]# connect aa:bb:cc:dd:ee:ff
    Attempting to connect to aa:bb:cc:dd:ee:ff
    [CHG] Device aa:bb:cc:dd:ee:ff Connected: yes
    Connection successful
    [CHG] Device aa:bb:cc:dd:ee:ff ServicesResolved: yes
    [JBL Xtreme]#
    

    这意味着您是否可以运行命令bluetoothctl,然后在[bluetooth]#提示符下输入connect aa:bb:cc:dd:ee:ff蓝牙设备将连接。

    因此,这可以通过终端中的单个命令来完成,在您第一次登录后打开终端并运行此命令。

    echo "connect aa:bb:cc:dd:ee:ff" | bluetoothctl

    例子:

    pratap@i7-4770:~$ echo "connect aa:bb:cc:dd:ee:ff" | bluetoothctl
    [NEW] Controller xx:xx:xx:xx:xx:xx i7-4770 [default]
    [NEW] Device aa:bb:cc:dd:ee:ff JBL Xtreme
    [NEW] Device xx:xx:xx:xx:xx:xx HUAWEI P smart
    Agent registered
    [bluetooth]# connect aa:bb:cc:dd:ee:ff
    Attempting to connect to aa:bb:cc:dd:ee:ff
    Agent unregistered
    [DEL] Controller xx:xx:xx:xx:xx:xx i7-4770 [default]
    pratap@i7-4770:~$
    

    所以命令echo "connect aa:bb:cc:dd:ee:ff" | bluetoothctl正在工作..

    这意味着如果我们可以在登录时运行此命令而无需人工干预.. 已配对且在启动时已打开的蓝牙设备将以上述手动方式连接..


    1. mkdir ~/bin(如果您还没有创建此目录。否则忽略此步骤)

    2. touch ~/bin/btautoconnect.sh

    3. gedit ~/bin/btautoconnect.sh

    粘贴以下内容:

    #!/bin/bash
    
    bluetoothctl
    sleep 10
    echo "connect aa:bb:cc:dd:ee:ff" | bluetoothctl
    sleep 12
    echo "connect aa:bb:cc:dd:ee:ff" | bluetoothctl
    exit
    
    1. 保存并关闭文件。

    2. chmod +x ~/bin/btautoconnect.sh

    创建一个名为 .desktop 的btautoconnect.desktop文件~/.config/autostart/

    1. touch ~/.config/autostart/btautoconnect.desktop

    使用 gedit 打开该字段并复制粘贴此命令下方的内容

    1. gedit ~/.config/autostart/btautoconnect.desktop

    内容:

    [Desktop Entry]
    Type=Application
    Exec=/bin/bash /home/pratap/bin/btautoconnect.sh
    Hidden=false
    NoDisplay=false
    X-GNOME-Autostart-enabled=true
    Name=BTAutoConnect
    X-GNOME-Autostart-Delay=5
    Comment=Starts Bluetooth speaker
    
    1. 重新启动以在 10 到 20 秒内登录后看到连接的 BT 设备.. 没有任何人工交互..

    学分:https ://ubuntuforums.org/showthread.php?t=2365083

    • 3
  2. dschinn1001
    2019-09-05T14:27:25+08:002019-09-05T14:27:25+08:00

    在 Ubuntu 中,声音问题是由于安装的驱动程序造成的。如果这个扬声器是最新和最时尚的硬件,那么你就没有什么好机会了,必须等待 2 到 8 个月,直到驱动程序出现在 Linux 社区。但是您可以尝试在终端中安装以下软件包:

    sudo apt-get 安装 amarok 节奏盒

    重启

    然后打开蓝牙,看看你的音箱是否支持:

    • 打开活动概览并开始输入蓝牙。
    • 点击蓝牙打开面板。
    • 将顶部的开关设置为 ON。

    祝你好运或耐心等待最多 8 个月。

    • 0

相关问题

  • 从网络广播录制声音

  • 播放声音时延迟

  • 5.1环绕声[关闭]

  • 声音,在多个程序之间停止

  • 即使插入耳机,我的扬声器也会发出声音[关闭]

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve