I had a similar problem. I solved it by listening to dbus-monitor and running my script under a particular bluetooth event. In particular, dbus-monitor "interface='org.blueman.Applet',member='MenuChanged'"| while read -r line; do notify-send 'my bluetooth keyboard has just connected! High time to run my script' ./my_script.sh done