feat: add volume and bluetooth info

This commit is contained in:
Krzysztof Rudnicki 2024-11-15 11:59:05 +01:00
parent b6a36b2789
commit 1e3e70cfe8
3 changed files with 46 additions and 0 deletions

17
i3blocks/bluetooth.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/bash
# Get Bluetooth device info
bluetooth_info=$(bluetoothctl info)
# Check if Bluetooth is connected
if echo "$bluetooth_info" | grep -q "Connected: yes"; then
device=$(echo "$bluetooth_info" | grep "Alias" | cut -d ' ' -f2-)
echo "$device" #  is the Bluetooth icon
echo
echo "#50FA7B" # Green for connected
else
echo " Disconnected"
echo
echo "#FF5555" # Red for disconnected
fi

View File

@ -22,6 +22,15 @@ command=df -h / | awk '/\// {print " Disk: " $3 "/" $2}' #  for disk
interval=30
color=#50FA7B
[volume]
command=~/.config/i3blocks/volume.sh
interval=1
[bluetooth]
command=~/.config/i3blocks/bluetooth.sh
interval=5
[ethernet]
command=ip -o -4 addr show enp6s0 | awk '{print " LAN: "$4}' || echo " LAN: down" #  for Ethernet
interval=10

20
i3blocks/volume.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
# Get the current volume level and mute status
volume=$(pactl get-sink-volume @DEFAULT_SINK@ | awk '{print $5}' | tr -d '%')
mute=$(pactl get-sink-mute @DEFAULT_SINK@ | awk '{print $2}')
# Determine icon and color based on mute status
if [ "$mute" = "yes" ]; then
icon="🔇" # Muted
color="#FF5555" # Red
else
icon="🔊" # Volume icon
color="#50FA7B" # Green
fi
# Output the volume with icon and color
echo "$icon $volume%"
echo
echo $color