slight speed-up
This commit is contained in:
parent
30d11324aa
commit
c262c29072
17
bt
17
bt
@ -15,14 +15,6 @@ actions="$(printf 'pair\nunpair\n')"
|
|||||||
|
|
||||||
[ "$AUTOTRUST" = false ] && actions="$(printf '%s\ntrust\n' "$actions")"
|
[ "$AUTOTRUST" = false ] && actions="$(printf '%s\ntrust\n' "$actions")"
|
||||||
|
|
||||||
#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 date nl; do
|
|
||||||
if ! hash "$prog" 2>/dev/null; then
|
|
||||||
printf 'bthandler: %s: command not found\n' "$prog" >&2
|
|
||||||
exit 127
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
power(){
|
power(){
|
||||||
powerstatus="$( bluetoothctl show | grep Powered | awk '{print $2}' )"
|
powerstatus="$( bluetoothctl show | grep Powered | awk '{print $2}' )"
|
||||||
if [ "$powerstatus" = "no" ]; then
|
if [ "$powerstatus" = "no" ]; then
|
||||||
@ -127,8 +119,13 @@ done
|
|||||||
powerstatus="$( bluetoothctl show | grep Powered | awk '{print $2}' )"
|
powerstatus="$( bluetoothctl show | grep Powered | awk '{print $2}' )"
|
||||||
poweroption="$( echo "$powerstatus" | sed 's/yes/power off/; s/no/power on/' )"
|
poweroption="$( echo "$powerstatus" | sed 's/yes/power off/; s/no/power on/' )"
|
||||||
#Don't print empty device list, removes unnecessary empty choice in dmenu
|
#Don't print empty device list, removes unnecessary empty choice in dmenu
|
||||||
[ "$disp_devices" = "" ] && choice=$( printf "%s\n%s" "$actions" "$poweroption" | dmenu -i -p 'What BT action would you like to perform:' | tr -d '🔗')
|
if [ "$disp_devices" = "" ];then
|
||||||
[ "$disp_devices" != "" ] && choice=$( ( echo "$disp_devices_with_links" && printf "%s\n%s" "$actions" "$poweroption" ) | dmenu -i -p 'What BT action would you like to perform:' | tr -d '🔗')
|
choice=$( printf "%s\n%s" "$actions" "$poweroption" |
|
||||||
|
dmenu -i -p 'What BT action would you like to perform:')
|
||||||
|
else
|
||||||
|
choice=$( ( echo "$disp_devices_with_links" && printf "%s\n%s" "$actions" "$poweroption" ) |
|
||||||
|
dmenu -i -p 'What BT action would you like to perform:' | tr -d '🔗')
|
||||||
|
fi
|
||||||
|
|
||||||
cleanup(){
|
cleanup(){
|
||||||
scan off
|
scan off
|
||||||
|
Loading…
Reference in New Issue
Block a user