4

Linux 系统接收通过蓝牙传输的文件

 2 years ago
source link: https://blog.lilydjwg.me/2015/6/7/receive-files-over-bluetooth-in-linux.96155.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Linux 系统接收通过蓝牙传输的文件

本文来自依云's Blog,转载请注明。

首先安装 bluez 包。我用的版本是 5.30。其次安装 blueman。

启动蓝牙服务:

systemctl start bluetooth.service

然后使用 blueman-manager 之类的命令启动 blueman。这时会在系统托盘看到蓝牙图标。点右键选择「添加新设备…」,完成配对。

然后,如果是要往手机发文件的话,是没有问题的,但是收的话,会失败。原因是,默认接收文件前会先询问用户要不要接收,而 blueman 不知道怎么搞的根本没反应……

解决方案是:直接启动一个默认接收文件的 obexd 就好了:

killall obexd
/usr/lib/bluetooth/obexd -r tmpfs -n -a

-r指定收到的文件存哪里,默认是 $XDG_CACHE_DIR 下的 obexd 目录,即默认是 ~/.cache/obexd。这里的路径是相对于用户主目录的。

-n是不要以守护模式运行,会把日志输出到终端而不是系统日志。

-a就是重点——接收所有文件——了。

obex 这套东西的文档在/usr/share/doc/bluez/dbus-apis/下有。

Linux 下遇到点问题还真是折腾,声称完成某一功能的软件一大堆,结果装好了,要么根本不知道怎么用(gnome-bluetooth、bluedevil),要么适用版本不匹配(obexpushd、ArchWiki 等网上的过时信息),要么有 bug 用不了(blueman)。

不过好的一点是,不涉及闭源的软件和协议,而又有足够的时间和能力的话,问题总是能够解决的。不像 Windows 或者 Android,遇到问题两眼一摸黑,只能不断地重试和重装,看看人品会不会爆发一下。

最后,折腾好久终于传输成功的照片:

北京好不容易下了场大雨,没想到雨后还出现了彩虹~

发送到 Kindle


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK