ubuntu蓝牙耳机切换到头戴式耳机 参考https://askubuntu.com/questions/831331/failed-to-change-profile-to-headset-head-unit 备份 1. sudo apt install ofono 2. Goto /etc/pulse/default.pa find the line load-module module-bluetooth-discover and change it in load-module module-bluetooth-discover headset=ofono. 3. Add the user pulse to group bluetooth to grant the permission: sudo usermod -aG bluetooth pulse (probably it's already correct) 4. VERY IMPORTANT: To grant the permission, add this to /etc/dbus-1/system.d/ofono.conf (before ): 5. Provide phonesim to ofono. In order to make ofono work, you have to provide a modem to it! You can install a modem emulator called phonesim (implemented by ofono) to make it work: 6. install ofono-phonesim (in some distros it is called phonesim). in Ubuntu 18.04 (for Ubuntu 20.04 follow this link): sudo apt install ofono-phonesim sudo add-apt-repository ppa:smoser/bluetooth sudo apt-get update sudo apt-get install ofono-phonesim 7. Configure phonesim by adding the following lines to /etc/ofono/phonesim.conf: [phonesim] Driver=phonesim Address=127.0.0.1 Port=12345 8. Restart ofono:`sudo systemctl restart ofono.service` 9. Start phonesim:`ofono-phonesim -p 12345 /usr/share/phonesim/default.xml` 10. To make sure phonesim is started correctly you can clone the ofono repo and use their test scripts: cd /tmp git clone git://git.kernel.org/pub/scm/network/ofono/ofono.git cd ofono/test ./enable-modem ./online-modem ./list-modems ## 20.04自动启动 /etc/systemd/system/ofono-phonesim.service ``` [Unit] Description=Run ofono-phonesim in the background [Service] ExecStart=ofono-phonesim -p 12345 /usr/share/phonesim/default.xml Type=simple RemainAfterExit=yes [Install] WantedBy=multi-user.target ``` /etc/systemd/system/phonesim-enable-modem.service: ``` [Unit] Description=Enable and online phonesim modem Requires=ofono-phonesim.service [Service] ExecStart=//test/enable-modem /phonesim ExecStart=//test/online-modem /phonesim Type=oneshot RemainAfterExit=yes [Install] WantedBy=multi-user.target ``` Then run the following commands to run both daemons: ``` sudo systemctl daemon-reload sudo systemctl enable ofono-phonesim.service sudo systemctl enable phonesim-enable-modem.service sudo service phonesim-enable-modem start ``` Check if the service is running with ``` sudo service phonesim-enable-modem status ``` ## 重启服务 上面都弄好后,可以用下面的命令随时重启服务 ``` sudo systemctl restart ofono.service sudo systemctl restart ofono-phonesim sudo systemctl restart phonesim-enable-modem ``` 来自 大脸猪 写于 2021-03-11 20:15 -- 更新于2021-03-12 15:58 -- 0 条评论