power menu, redshift, polybar

This commit is contained in:
azpsen
2024-01-28 16:37:10 -06:00
parent 89516a6ce1
commit 319b44ecbd
307 changed files with 7642 additions and 5 deletions

View File

@@ -0,0 +1,30 @@
# Script: system-bluetooth-bluetoothctl
A shell script which displays the status of bluetooth and the paired devices.
Use the toggle option to power on the controller and try to connect to all paired devices or to disconnect all connections and turn off the controller.
![system-bluetooth-bluetoothctl](screenshots/1.png)
## Dependencies
* `bluetoothctl`
## Configuration
Use the `set-alias` feature of `bluetoothctl` to customize your device names.
To enable battery level detection set `Experimental = true` in `/etc/bluetooth/main.conf`.
## Module
```ini
[module/system-bluetooth-bluetoothctl]
type = custom/script
exec = ~/polybar-scripts/system-bluetooth-bluetoothctl.sh
tail = true
click-left = ~/polybar-scripts/system-bluetooth-bluetoothctl.sh --toggle &
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@@ -0,0 +1,77 @@
#!/bin/sh
bluetooth_print() {
bluetoothctl | grep --line-buffered 'Device\|#' | while read -r REPLY; do
if [ "$(systemctl is-active "bluetooth.service")" = "active" ]; then
printf '#1'
devices_paired=$(bluetoothctl devices Paired | grep Device | cut -d ' ' -f 2)
counter=0
for device in $devices_paired; do
device_info=$(bluetoothctl info "$device")
if echo "$device_info" | grep -q "Connected: yes"; then
device_output=$(echo "$device_info" | grep "Alias" | cut -d ' ' -f 2-)
device_battery_percent=$(echo "$device_info" | grep "Battery Percentage" | awk -F'[()]' '{print $2}')
if [ -n "$device_battery_percent" ]; then
if [ "$device_battery_percent" -gt 90 ]; then
device_battery_icon="#25"
elif [ "$device_battery_percent" -gt 60 ]; then
device_battery_icon="#24"
elif [ "$device_battery_percent" -gt 35 ]; then
device_battery_icon="#23"
elif [ "$device_battery_percent" -gt 10 ]; then
device_battery_icon="#22"
else
device_battery_icon="#21"
fi
device_output="$device_output $device_battery_icon $device_battery_percent%"
fi
if [ $counter -gt 0 ]; then
printf ", %s" "$device_output"
else
printf " %s" "$device_output"
fi
counter=$((counter + 1))
fi
done
printf '\n'
else
echo "#2"
fi
done
}
bluetooth_toggle() {
if bluetoothctl show | grep -q "Powered: no"; then
bluetoothctl power on >> /dev/null
sleep 1
devices_paired=$(bluetoothctl devices Paired | grep Device | cut -d ' ' -f 2)
echo "$devices_paired" | while read -r line; do
bluetoothctl connect "$line" >> /dev/null
done
else
devices_paired=$(bluetoothctl devices Paired | grep Device | cut -d ' ' -f 2)
echo "$devices_paired" | while read -r line; do
bluetoothctl disconnect "$line" >> /dev/null
done
bluetoothctl power off >> /dev/null
fi
}
case "$1" in
--toggle)
bluetooth_toggle
;;
*)
bluetooth_print
;;
esac