feat: wifi view, battery status shorter

This commit is contained in:
Krzysztof Rudnicki 2024-11-15 14:23:38 +01:00
parent d3006d546e
commit 5fa0d8321c
4 changed files with 31 additions and 4 deletions

View File

@ -6,7 +6,6 @@ acpi -b | awk -F', ' '
split($3, time, " ")
printf " %d%%", percent[1]
if (time[1] != "") printf ", %s", time[1]
if ($1 ~ /Charging/) printf ", Charging"
if ($1 ~ /Charging/) printf ", "
printf "\n"
}'
}'

View File

@ -43,6 +43,10 @@ color=#50FA7B
command=ip -o -4 addr show enp6s0 | awk '{print " LAN: "$4}' || echo " LAN: down" #  for Ethernet
interval=10
[wifi]
command=~/.config/i3blocks/wifi_monitor.sh
interval=10
[network_monitor]
command=~/.config/i3blocks/network_monitor.sh
interval=1

24
i3blocks/wifi_monitor.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
# Detect the active WiFi interface
wifi_interface=$(iw dev | awk '$1=="Interface"{print $2}')
# If no WiFi interface is found, exit
if [ -z "$wifi_interface" ]; then
echo " WiFi: down"
exit 1
fi
# Get the WiFi details
wifi_info=$(iwconfig $wifi_interface 2>/dev/null)
# Extract the SSID and signal strength
ssid=$(echo "$wifi_info" | awk -F '"' '/ESSID/ {print $2}')
signal=$(echo "$wifi_info" | awk '/Signal level/ {print $4}' | tr -d 'level=')
# Output the result
if [ -z "$ssid" ]; then
echo " down"
else
echo "$ssid ($signal dBm)"
fi

View File

@ -1,5 +1,5 @@
#!/bin/sh
yes | sudo pacman -S --needed ttf-dejavu noto-fonts ttf-font-awesome bc intel-gpu-tools jq
yes | sudo pacman -S --needed ttf-dejavu noto-fonts ttf-font-awesome bc intel-gpu-tools jq iw
sudo setcap cap_perfmon+ep /usr/bin/intel_gpu_top
cp -r i3blocks ~/.config/
cp -r i3 ~/.config/