M doc/PACKAGES.md => doc/PACKAGES.md +1 -0
@@ 16,6 16,7 @@ Note that it is not an exact match as extra patches might be added by the distro
| aria2 | download utility | [GitHub](https://github.com/aria2/aria2) | [1.35.0](https://github.com/aria2/aria2/releases/tag/release-1.35.0) |
| bemenu | dynamic menu | [GitHub](https://github.com/Cloudef/bemenu) | [0.6.2](https://github.com/Cloudef/bemenu/releases/tag/0.6.2) |
| bluez-utils | Bluetooth utilities | [kernel.org](https://git.kernel.org/pub/scm/bluetooth/bluez.git) | [5.60](https://git.kernel.org/pub/scm/bluetooth/bluez.git/tag/?h=5.60) |
+| bluez-tools | Bluetooth extra utilities | [GitHub](https://github.com/khvzak/bluez-tools) | [0.2.0](https://github.com/khvzak/bluez-tools/commit/7cb788c9c43facfd2d14ff50e16d6a19f033a6a7) |
| catimg | image renderer | [GitHub](https://github.com/posva/catimg) | [2.7.0](https://github.com/posva/catimg/releases/tag/2.7.0) |
| coreutils | basic utilities | [GNU](http://git.savannah.gnu.org/cgit/coreutils.git/) | [8.32](http://git.savannah.gnu.org/cgit/coreutils.git/tag/?h=v8.32) |
| ctags | sources indexation | [GitHub](https://github.com/universal-ctags/ctags) | [1:r20210106+g08b1c490](https://github.com/universal-ctags/ctags/releases/tag/p5.9.20210110.0) |
M files/configs/zsh/Makefile => files/configs/zsh/Makefile +1 -0
@@ 18,6 18,7 @@ zsh-configs:
$(setup_file)/configs/zsh/config.d/prompt.zsh > $(DESTDIR)$(HOME)/.zsh/config.d/prompt.zsh
$(setup_file)/configs/zsh/config.d/variables.zsh > $(DESTDIR)$(HOME)/.zsh/config.d/variables.zsh
$(setup_file)/configs/zsh/completions/_backup > $(DESTDIR)$(HOME)/.zsh/completions/_backup
+ $(setup_file)/configs/zsh/completions/_bluetooth > $(DESTDIR)$(HOME)/.zsh/completions/_bluetooth
$(setup_file)/configs/zsh/completions/_do-not-disturb > $(DESTDIR)$(HOME)/.zsh/completions/_do-not-disturb
$(setup_file)/configs/zsh/completions/_documentation > $(DESTDIR)$(HOME)/.zsh/completions/_documentation
$(setup_file)/configs/zsh/completions/_extract-tokens > $(DESTDIR)$(HOME)/.zsh/completions/_extract-tokens
A files/configs/zsh/completions/_bluetooth => files/configs/zsh/completions/_bluetooth +31 -0
@@ 0,0 1,31 @@
+#compdef bluetooth
+
+_actions() {
+ local actions=(
+ connect
+ disconnect
+ receive
+ send
+ )
+
+ compadd "$@" $actions
+}
+
+_device_aliases() {
+ if [ $words[CURRENT-1] != 'receive' ]; then
+ local device_aliases=( "${(@f)$( bluetoothctl paired-devices | cut -d' ' -f3 )}" )
+ compadd "$@" $device_aliases
+ fi
+}
+
+_send_files() {
+ if [ $words[CURRENT-2] = 'send' ]; then
+ _path_files
+ fi
+}
+
+
+_arguments \
+ '1:action:_actions' \
+ '2:device_alias:_device_aliases' \
+ '3:file:_send_files'
M files/configs/zsh/config.d/aliases.zsh => files/configs/zsh/config.d/aliases.zsh +5 -3
@@ 20,9 20,11 @@ alias dk='cd "${XDG_DESKTOP_DIR:-$HOME/Desktop}"'
alias dw='cd "${XDG_DOWNLOAD_DIR:-$HOME/Downloads}"'
alias nt='cd "${XDG_NOTES_DIR:-$HOME/Notes}"'
-# bluetooth connections
-alias btc='bluetoothctl connect'
-alias btd='bluetoothctl disconnect'
+# bluetooth
+alias btc='bluetooth connect'
+alias btd='bluetooth disconnect'
+alias btr='bluetooth receive'
+alias bts='bluetooth send'
# source directory aliases
alias .a='cat .aliases 2> /dev/null && . ./.aliases'
M files/docs/shell/Makefile => files/docs/shell/Makefile +1 -0
@@ 6,6 6,7 @@ shell-docs:
$(setup_file)/docs/shell/backup.scd | scdoc > $(DESTDIR)$(DATA_DIR)/man/man1/backup.1perso
$(setup_file)/docs/shell/base.scd | scdoc > $(DESTDIR)$(DATA_DIR)/man/man1/base.1perso
$(setup_file)/docs/shell/battery-status.scd | scdoc > $(DESTDIR)$(DATA_DIR)/man/man1/battery-status.1perso
+ $(setup_file)/docs/shell/bluetooth.scd | scdoc > $(DESTDIR)$(DATA_DIR)/man/man1/bluetooth.1perso
$(setup_file)/docs/shell/calculate.scd | scdoc > $(DESTDIR)$(DATA_DIR)/man/man1/calculate.1perso
$(setup_file)/docs/shell/check-notify-low-battery.scd | scdoc > $(DESTDIR)$(DATA_DIR)/man/man1/check-notify-low-battery.1perso
$(setup_file)/docs/shell/color-picker.scd | scdoc > $(DESTDIR)$(DATA_DIR)/man/man1/color-picker.1perso
A files/docs/shell/bluetooth.scd => files/docs/shell/bluetooth.scd +59 -0
@@ 0,0 1,59 @@
+bluetooth(1perso)
+
+# NAME
+
+bluetooth - Bluetooth commands
+
+# SYNOPSIS
+
+bluetooth *connect* _device_alias_
+
+bluetooth *disconnect* [ _device_alias_ ]
+
+bluetooth *receive*
+
+bluetooth *send* _device_alias_ _file_
+
+# DESCRIPTION
+
+Bluetooth commands
+
+# OPTIONS
+
+None
+
+# OPERANDS
+
+*connect*
+ Connect to a bluetooth device
+
+*disconnect*
+ Disconnect from a bluetooth device
+
+*receive*
+ Prepare to receive files
+
+*send*
+ Send file to a bluetooth device
+
+_device_alias_
+ Alias of the bluetooth device
+
+_file_
+ Path of the file to send
+
+# ENVIRONMENT VARIABLES
+
+_XDG_DOWNLOAD_DIR_
+ Path to user-specific downloads directory++
+If unset, defaults to $HOME/Downloads
+
+# FILES
+
+_$XDG_DOWNLOAD_DIR_
+ Directory containing the received files
+
+# DEPENDENCIES
+
+- bluetoothctl
+- bt-obex
M files/scripts/shell/Makefile => files/scripts/shell/Makefile +2 -0
@@ 6,6 6,7 @@ shell-scripts:
$(setup_file)/scripts/shell/backup > $(DESTDIR)$(BIN_DIR)/backup
$(setup_file)/scripts/shell/base > $(DESTDIR)$(BIN_DIR)/base
$(setup_file)/scripts/shell/battery-status > $(DESTDIR)$(BIN_DIR)/battery-status
+ $(setup_file)/scripts/shell/bluetooth > $(DESTDIR)$(BIN_DIR)/bluetooth
$(setup_file)/scripts/shell/calculate > $(DESTDIR)$(BIN_DIR)/calculate
$(setup_file)/scripts/shell/check-notify-low-battery > $(DESTDIR)$(BIN_DIR)/check-notify-low-battery
$(setup_file)/scripts/shell/color-picker > $(DESTDIR)$(BIN_DIR)/color-picker
@@ 51,6 52,7 @@ shell-scripts:
chmod +x $(DESTDIR)$(BIN_DIR)/backup
chmod +x $(DESTDIR)$(BIN_DIR)/base
chmod +x $(DESTDIR)$(BIN_DIR)/battery-status
+ chmod +x $(DESTDIR)$(BIN_DIR)/bluetooth
chmod +x $(DESTDIR)$(BIN_DIR)/calculate
chmod +x $(DESTDIR)$(BIN_DIR)/check-notify-low-battery
chmod +x $(DESTDIR)$(BIN_DIR)/color-picker
A files/scripts/shell/bluetooth => files/scripts/shell/bluetooth +76 -0
@@ 0,0 1,76 @@
+#!/bin/sh
+
+init_variables() {
+ COMMAND=${0##*/}
+
+ ACTION=
+ DEVICE_ALIAS=
+ FILE=
+}
+
+parse_command_line() {
+ ACTION="$1"
+ DEVICE_ALIAS="$2"
+
+ if [ "${ACTION}" = 'send' ]; then
+ FILE="$3"
+ fi
+}
+
+validate_command_line() {
+ if [ "${ACTION}" != 'connect' ] \
+ && [ "${ACTION}" != 'disconnect' ] \
+ && [ "${ACTION}" != 'receive' ] \
+ && [ "${ACTION}" != 'send' ]; then
+ exit_error "Invalid action '${ACTION}'"
+ fi
+
+ if [ "${ACTION}" = 'connect' ] || [ "${ACTION}" = 'send' ]; then
+ if [ -z "${DEVICE_ALIAS}" ]; then
+ exit_error "Missing device alias"
+ fi
+ fi
+
+ if [ "${ACTION}" = 'send' ]; then
+ if [ -z "${FILE}" ]; then
+ exit_error "Missing file argument"
+ fi
+ fi
+}
+
+exit_error() {
+ [ -z "$1" ] || echo "${COMMAND}: $1"
+ exit 1
+} >&2
+
+device_mac() {
+ bluetoothctl paired-devices \
+ | grep "$1$" \
+ | cut -d' ' -f2
+}
+
+bluetooth_connect() {
+ bluetoothctl connect "$( device_mac "${DEVICE_ALIAS}" )"
+}
+
+bluetooth_disconnect() {
+ if [ -n "${DEVICE_ALIAS}" ]; then
+ bluetoothctl disconnect "$( device_mac "${DEVICE_ALIAS}" )"
+ else
+ bluetoothctl disconnect
+ fi
+}
+
+bluetooth_receive() {
+ bt-obex -y -s "${XDG_DOWNLOAD_DIR:-$HOME/Downloads}" 2> /dev/null
+}
+
+bluetooth_send() {
+ bt-obex -p "$( device_mac "${DEVICE_ALIAS}" )" "${FILE}" 2> /dev/null
+}
+
+init_variables
+parse_command_line "$@"
+validate_command_line
+
+"bluetooth_${ACTION}"