finish(?) lsp config for nvim; add bt battery status to waybar; change wallpaper ellemayo
parent
f65bfbadb5
commit
5ff0fa7e71
@ -0,0 +1,8 @@
|
|||||||
|
return {
|
||||||
|
settings = {
|
||||||
|
init_options = {
|
||||||
|
["language_server_phpstan.enabled"] = false,
|
||||||
|
["language_server_psalm.enabled"] = false,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
Binary file not shown.
Before Width: | Height: | Size: 4.8 MiB After Width: | Height: | Size: 2.0 MiB |
@ -0,0 +1,54 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SCRIPTS_DIR=~/.config/waybar/scripts
|
||||||
|
|
||||||
|
get_battery_status() {
|
||||||
|
device_uuid=$1
|
||||||
|
device_uuid_slug=$(echo "$device_uuid" | sed 's/:/_/g')
|
||||||
|
device_upower_path=$(upower -e | grep "$device_uuid_slug")
|
||||||
|
if [[ "$?" != 0 ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
upower_out=$(upower -i "$device_upower_path")
|
||||||
|
percentage=$(echo "$upower_out" | grep 'percentage:' | grep -oe '[0-9]*%')
|
||||||
|
if [[ "$?" != 0 ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $percentage
|
||||||
|
}
|
||||||
|
|
||||||
|
# prepare devices to process
|
||||||
|
connected_devices=$1
|
||||||
|
if [[ "$connected_devices" == "" ]]; then
|
||||||
|
connected_devices=$($SCRIPTS_DIR/bt-connected.sh)
|
||||||
|
fi
|
||||||
|
if [[ "$connected_devices" == "" ]]; then
|
||||||
|
echo "no bluetooth devices connected" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
n=0
|
||||||
|
declare -A device_batteries
|
||||||
|
for device in ${connected_devices//\\n/ }; do
|
||||||
|
device_battery_percentage=$(get_battery_status "$device")
|
||||||
|
if [[ $? != 0 ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
n=$((n+1))
|
||||||
|
device_batteries[$device]=$device_battery_percentage
|
||||||
|
# echo "$device: $device_battery_percentage"
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ $n -eq 0 ]]; then
|
||||||
|
echo "cannot get battery status for any specified bluetooth device" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# TODO: do something else?
|
||||||
|
for device in ${!device_batteries[*]}; do
|
||||||
|
echo "$device ${device_batteries[$device]}"
|
||||||
|
done
|
||||||
|
|
@ -0,0 +1,52 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
ICON_BLUETOOTH=""
|
||||||
|
ICON_BATTERY_FULL=" "
|
||||||
|
ICON_BATTERY_THREE_QUARTERS=" "
|
||||||
|
ICON_BATTERY_HALF=" "
|
||||||
|
ICON_BATTERY_QUARTER=" "
|
||||||
|
ICON_BATTERY_EMPTY=" "
|
||||||
|
BLUETOOTH_BATTERY_STATUS=~/.config/waybar/scripts/bt-bat-status.sh
|
||||||
|
|
||||||
|
tooltip=""
|
||||||
|
|
||||||
|
statuses="$($BLUETOOTH_BATTERY_STATUS)"
|
||||||
|
if [[ $? != 0 ]]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
n=0
|
||||||
|
sum=0
|
||||||
|
IFS=$'\n'
|
||||||
|
for status in $statuses; do
|
||||||
|
uuid=$(echo "$status" | cut -d' ' -f1)
|
||||||
|
name=$(bluetoothctl info "$uuid" | grep -oe 'Name: .*' | awk 'match($0, "Name: (.*)", m){print m[1]}')
|
||||||
|
percent=$(echo "$status" | cut -d' ' -f2 | grep -oe '[0-9]*')
|
||||||
|
|
||||||
|
tooltip="$tooltip$name: $percent%\n"
|
||||||
|
|
||||||
|
n=$((n+1))
|
||||||
|
sum=$((sum+percent))
|
||||||
|
done
|
||||||
|
IFS=' '
|
||||||
|
|
||||||
|
avg=$((sum / n))
|
||||||
|
|
||||||
|
ICON_BATTERY=""
|
||||||
|
if [[ $avg -ge 90 ]]; then
|
||||||
|
ICON_BATTERY=$ICON_BATTERY_FULL
|
||||||
|
elif [[ $avg -ge 75 ]]; then
|
||||||
|
ICON_BATTERY=$ICON_BATTERY_THREE_QUARTERS
|
||||||
|
elif [[ $avg -ge 50 ]]; then
|
||||||
|
ICON_BATTERY=$ICON_BATTERY_HALF
|
||||||
|
elif [[ $avg -ge 25 ]]; then
|
||||||
|
ICON_BATTERY=$ICON_BATTERY_QUARTER
|
||||||
|
else
|
||||||
|
ICON_BATTERY=$ICON_BATTERY_EMPTY
|
||||||
|
fi
|
||||||
|
|
||||||
|
tooltip=${tooltip%\\n}
|
||||||
|
|
||||||
|
echo "{\"text\": \"$ICON_BLUETOOTH $ICON_BATTERY\", \"tooltip\": \"$tooltip\"}"
|
||||||
|
|
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
bluetoothctl devices | cut -f2 -d' ' | while read uuid; do bluetoothctl info $uuid | grep -B9 -e 'Connected: yes' | grep -e 'Device' | cut -f2 -d' '; done
|
Loading…
Reference in New Issue