diff options
| author | Robert Günzler <r@gnzler.io> | 2026-09-27 17:38:39 +0200 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2026-09-27 17:38:39 +0200 |
| commit | 0860db73ae6fd9a6f6347219d820bf026a6b8b91 (patch) | |
| tree | 11318c3670d1c32c5aa0bf404c22fba3bf63fc53 /bin/blum | |
| parent | 4e34cbf9673aeaba252e01df554a0d204e83c5e2 (diff) | |
| download | dotfiles-master.tar.gz | |
Automated-commit-by: dots Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to '')
| -rwxr-xr-x | bin/blum | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/bin/blum b/bin/blum index 19c2aef..6f65f55 100755 --- a/bin/blum +++ b/bin/blum @@ -13,7 +13,8 @@ main() { if ! bt_enabled; then fuzl_action_add "enable" "" "Enable Bluetooth" else - connected=$(bt_devices Connected | bt_devices_getname) + # XXX: handle multiple + connected=$(bt_devices Connected | tail -1 | bt_devices_getname) if [ -n "$connected" ]; then fuzl_action_add "disconnect" "" "Connected to $connected" fi @@ -35,7 +36,6 @@ bt_devices() { echo "devices" "${1:-}" | bluetoothctl | awk '/^Device /{match($0, /[0-9A-F:]{17}/); mac=substr($0,RSTART,RLENGTH); name=substr($0,RSTART+RLENGTH+1); print mac "\t" name}' } - bt_devices_getmac() { awk -F '\t' '{print $1}' } @@ -44,19 +44,40 @@ bt_devices_getname() { awk -F '\t' '{print $2}' } +amagiri_mac='3C:38:F4:5D:3D:49' +bt_tether_amagiri_connected() { + nmcli device show "$amagiri_mac" | + grep -i '^general.state' | + grep -q 'connected' +} +bt_tether_amagiri_up() { + echo "connect" "$amagiri_mac" | + fuzl_try -- bluetoothctl + fuzl_try -- nmcli device connect "$amagiri_mac" + fuzl_try -- nmcli radio wifi off + fuzl_notification "tethered" "amagiri" +} +bt_tether_amagiri_down() { + fuzl_try -- nmcli device disconnect "$amagiri_mac" + echo "disconnect" "$amagiri_mac" | + fuzl_try -- bluetoothctl + fuzl_try -- nmcli radio wifi on + fuzl_notification "untethered" "amagiri" +} + # # actions # blum_enable() { fuzl_try -- doas -n rc-service bluetooth start - fuzl_notification "enabled" "-" + fuzl_notification "enabled" "service started" main } blum_disable() { fuzl_try -- doas -n rc-service bluetooth stop - fuzl_notification "disabled" "-" + fuzl_notification "disabled" "service stopped" } blum_disconnect() { @@ -89,12 +110,11 @@ blum_repl() { } blum_tether_amagiri() { - local amagiri_mac='3C:38:F4:5D:3D:49' - local amagiri_net='e4e75ff7-b907-43b7-98b7-e0bf94a56d08' - echo "connect" "$amagiri_mac" | fuzl_try -- bluetoothctl - fuzl_notification "connected" "amagiri" - fuzl_try -- nmcli connection up "$amagiri_net" - fuzl_notification "network up" "amagiri" + if ! bt_tether_amagiri_connected; then + bt_tether_amagiri_up + else + bt_tether_amagiri_down + fi } main |