-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_bluetooth.sh
More file actions
executable file
·29 lines (25 loc) · 895 Bytes
/
get_bluetooth.sh
File metadata and controls
executable file
·29 lines (25 loc) · 895 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
#
# This script displays 'Bluetooth: <name>' if connected
# Else, this displays 'Bluetooth SYMBOL' where SYMBOL is:
# ✓ if Bluetooth is off (it's correct that there is no connection)
# ✗ if Bluetooth is on (should have a connection but doesn't)
# It outputs it in green or red if connected or not, using pango markup
# following command sets $symbol to ✓ if bluetooth is off
dead=$(systemctl status bluetooth | grep "dead")
# is there a connection?
if [[ "${dead}" ]]
then
echo -e "<span color='#FF1D8E'>Bluetooth ✓</span>"
else
# get the connected device's name, if there is one
name=$(bluetoothctl -- info | grep Name | cut -d" " -f2-)
if [[ "${name}" ]]
then
# output green, and name
echo -e "<span color='green'>Bluetooth: ${name}</span>"
else
echo -e "<span color='#FF1D8E'>Bluetooth ✗</span>"
fi
fi
exit 0