From cb3d6da5f19085fe62ddb2a92802066c744857f6 Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Tue, 21 Apr 2020 21:17:02 +0200 Subject: [PATCH] checks for all necessary programs at startup now --- bthandler | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bthandler b/bthandler index e692da3..41c223a 100755 --- a/bthandler +++ b/bthandler @@ -4,6 +4,15 @@ SCAN_PERIOD=5 BLACKLIST=$HOME/.local/bin/tools/bt_blacklist actions="turn off\nturn on\npair" +#Checks for necessary programs to be present. Very unlikely not to be present but let's just err on the safer side. +for prog in dmenu bluetoothctl awk cat; do + if ! hash "$prog" 2>/dev/null; then + printf 'bthandler: %s: command not found\n' "$prog" >&2 + exit 127 + fi +done + + bluetoothctl paired-devices | awk '{print $2}' > /tmp/bt_IDS bluetoothctl paired-devices | awk '{for (i=3; i /tmp/paired_devices grep -vf "$BLACKLIST" /tmp/paired_devices > /tmp/disp_devices @@ -19,7 +28,7 @@ cleanup(){ rm -f /tmp/paired_devices rm -f /tmp/new_devices rm -f /tmp/disp_devices - bluetoothctl scan off 2> /dev/null + bluetoothctl scan off > /dev/null exit }