Consistency of dmenu scripts.
This commit is contained in:
parent
299f43a491
commit
a3aff0e7e8
3 changed files with 29 additions and 29 deletions
|
@ -17,8 +17,8 @@
|
|||
# Arch repositories: rofi, bluez-utils (contains bluetoothctl)
|
||||
|
||||
# Constants
|
||||
divider="---------"
|
||||
goback="Back"
|
||||
divider="----------"
|
||||
goback="back"
|
||||
|
||||
# Checks if bluetooth controller is powered on
|
||||
power_on() {
|
||||
|
@ -46,10 +46,10 @@ toggle_power() {
|
|||
# Checks if controller is scanning for new devices
|
||||
scan_on() {
|
||||
if bluetoothctl show | grep -q "Discovering: yes"; then
|
||||
echo "Scan: on"
|
||||
echo "scan: on"
|
||||
return 0
|
||||
else
|
||||
echo "Scan: off"
|
||||
echo "scan: off"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ toggle_scan() {
|
|||
show_menu
|
||||
else
|
||||
bluetoothctl scan on &
|
||||
echo "Scanning..."
|
||||
echo "scanning..."
|
||||
sleep 5
|
||||
show_menu
|
||||
fi
|
||||
|
@ -71,10 +71,10 @@ toggle_scan() {
|
|||
# Checks if controller is able to pair to devices
|
||||
pairable_on() {
|
||||
if bluetoothctl show | grep -q "Pairable: yes"; then
|
||||
echo "Pairable: on"
|
||||
echo "pairable: on"
|
||||
return 0
|
||||
else
|
||||
echo "Pairable: off"
|
||||
echo "pairable: off"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
@ -93,10 +93,10 @@ toggle_pairable() {
|
|||
# Checks if controller is discoverable by other devices
|
||||
discoverable_on() {
|
||||
if bluetoothctl show | grep -q "Discoverable: yes"; then
|
||||
echo "Discoverable: on"
|
||||
echo "discoverable: on"
|
||||
return 0
|
||||
else
|
||||
echo "Discoverable: off"
|
||||
echo "discoverable: off"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
@ -137,10 +137,10 @@ toggle_connection() {
|
|||
device_paired() {
|
||||
device_info=$(bluetoothctl info "$1")
|
||||
if echo "$device_info" | grep -q "Paired: yes"; then
|
||||
echo "Paired: yes"
|
||||
echo "paired: yes"
|
||||
return 0
|
||||
else
|
||||
echo "Paired: no"
|
||||
echo "paired: no"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
@ -160,10 +160,10 @@ toggle_paired() {
|
|||
device_trusted() {
|
||||
device_info=$(bluetoothctl info "$1")
|
||||
if echo "$device_info" | grep -q "Trusted: yes"; then
|
||||
echo "Trusted: yes"
|
||||
echo "trusted: yes"
|
||||
return 0
|
||||
else
|
||||
echo "Trusted: no"
|
||||
echo "trusted: no"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
@ -217,13 +217,13 @@ device_menu() {
|
|||
|
||||
# Build options
|
||||
if device_connected $mac; then
|
||||
connected="Connected: yes"
|
||||
connected="connected: yes"
|
||||
else
|
||||
connected="Connected: no"
|
||||
connected="connected: no"
|
||||
fi
|
||||
paired=$(device_paired $mac)
|
||||
trusted=$(device_trusted $mac)
|
||||
options="$connected\n$paired\n$trusted\n$divider\n$goback\nExit"
|
||||
options="$connected\n$paired\n$trusted\n$divider\n$goback\nexit"
|
||||
|
||||
# Open rofi menu, read chosen option
|
||||
chosen="$(echo -e "$options" | $rofi_command "$device_name")"
|
||||
|
@ -231,7 +231,7 @@ device_menu() {
|
|||
# Match chosen option to command
|
||||
case $chosen in
|
||||
"" | $divider)
|
||||
echo "No option chosen."
|
||||
echo "no option chosen."
|
||||
;;
|
||||
$connected)
|
||||
toggle_connection $mac
|
||||
|
@ -252,7 +252,7 @@ device_menu() {
|
|||
show_menu() {
|
||||
# Get menu options
|
||||
if power_on; then
|
||||
power="Power: on"
|
||||
power="power: on"
|
||||
|
||||
# Human-readable names of devices, one per line
|
||||
# If scan is off, will only list paired devices
|
||||
|
@ -264,14 +264,14 @@ show_menu() {
|
|||
discoverable=$(discoverable_on)
|
||||
|
||||
# Options passed to rofi
|
||||
options="$devices\n$divider\n$power\n$scan\n$pairable\n$discoverable\nExit"
|
||||
options="$devices\n$divider\n$power\n$scan\n$pairable\n$discoverable\nexit"
|
||||
else
|
||||
power="Power: off"
|
||||
options="$power\nExit"
|
||||
power="power: off"
|
||||
options="$power\nexit"
|
||||
fi
|
||||
|
||||
# Open rofi menu, read chosen option
|
||||
chosen="$(echo -e "$options" | $rofi_command "Bluetooth:")"
|
||||
chosen="$(echo -e "$options" | $rofi_command "bluetooth")"
|
||||
|
||||
# Match chosen option to command
|
||||
case $chosen in
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue