2021-04-27 [長年日記]

_ [ubuntu][bluetooth]サスペンド復帰時にBTデバイスを自動接続する

BTスピーカを使っているがsuspendから復帰後に設定画面に行って接続している。アホくさい。

#!/bin/sh

#bluetoothctl paired-devices # 全部やるならこの結果を用いてloopすればいい

DEVICE=xx:xx:xx:xx:xx:xx # スピーカのID

if bluetoothctl info $DEVICE | grep "Connected: yes" > /dev/null ; then
  :
  #echo "Connected"
else
  #echo "Not connected. try to connect."
  bluetoothctl connect $DEVICE
fi

を作って、/lib/systemd/system-sleep/ からキックする.

lib/systemd/system-sleep/reconnect_bt_devices:

#!/bin/sh

case $1 in
  post)
    run_myscript
    ;;
esac

まだ実験してないけどな!

(2021/4/28追記)動いてなかった。ハハッ
systemdからキックする。動いた。
https://mongonta.com/f270-howto-exec-command-beforeafter-suspend-on-systemd/

手でやらなくていい!ああ素晴らしい。


検索キーワード:

記事

カテゴリ

Amazon | Android | apache | Arduino | bash | bluetooth | Books | CakePHP | CakePHP3 | CakePHP4 | Chrome | Chromebook | CodeIgniter | CSS | Docker | Eclipse | Emacs | etc | Firefox | Flask | Gadget | git | Gnome | Google | Heroku | HTML | hugo | Internet | iPhone | IS01 | IS03 | Java | JavaScript | json | Kotlin | Laravel | LINE | magento | mysql | nginx | nodejs | Oops | PC | Perl | php | Python | Qt | Ruby | ruby | Shell | ssh | tdiary | twitter | ubuntu | unix | VirtualBox | Web | Windows | windows | WindowsMobile | WX5 | YAML | zsh | ここか | そば | つくる | つり | できごと | アクアリウム | ギター | セキュリティ | プリンタ | ベース | ボクシング | ポエム | マネー | メシ | ラズパイ | 仕事 | 作家 | 壮絶 | 妄想 | 忘れる | 料理 | | 暑い | 痛い | 社会 | 自転車 | | 車輪 | | 野球 | 銭湯 | 音楽 |

全部 : / 今日 :

近頃

links

profile

もっとヒゲ伸ばしたい。