mirror of
https://github.com/LukeSmithxyz/voidrice.git
synced 2026-03-20 01:37:45 +01:00
Adding scripts for polybar
This commit is contained in:
parent
cc26f14f20
commit
44a4c3ae8e
12
.local/bin/polybar_scripts/bluetooth.sh
Executable file
12
.local/bin/polybar_scripts/bluetooth.sh
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
if [ $(bluetoothctl show | grep "Powered: yes" | wc -c) -eq 0 ]
|
||||||
|
then
|
||||||
|
echo "%{F#66ffffff}"
|
||||||
|
else
|
||||||
|
if [ $(echo info | bluetoothctl | grep 'Device' | wc -c) -eq 0 ]
|
||||||
|
then
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
echo "%{F#2193ff}"
|
||||||
|
fi
|
||||||
|
|
||||||
61
.local/bin/polybar_scripts/network_traffic
Executable file
61
.local/bin/polybar_scripts/network_traffic
Executable file
@ -0,0 +1,61 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
print_bytes() {
|
||||||
|
if [ "$1" -eq 0 ] || [ "$1" -lt 1000 ]; then
|
||||||
|
bytes="0 kB/s"
|
||||||
|
elif [ "$1" -lt 1000000 ]; then
|
||||||
|
bytes="$(echo "scale=0;$1/1000" | bc -l ) kB/s"
|
||||||
|
else
|
||||||
|
bytes="$(echo "scale=1;$1/1000000" | bc -l ) MB/s"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$bytes"
|
||||||
|
}
|
||||||
|
|
||||||
|
print_bit() {
|
||||||
|
if [ "$1" -eq 0 ] || [ "$1" -lt 10 ]; then
|
||||||
|
bit="0 B"
|
||||||
|
elif [ "$1" -lt 100 ]; then
|
||||||
|
bit="$(echo "scale=0;$1*8" | bc -l ) B"
|
||||||
|
elif [ "$1" -lt 100000 ]; then
|
||||||
|
bit="$(echo "scale=0;$1*8/1000" | bc -l ) K"
|
||||||
|
else
|
||||||
|
bit="$(echo "scale=1;$1*8/1000000" | bc -l ) M"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$bit"
|
||||||
|
}
|
||||||
|
|
||||||
|
INTERVAL=10
|
||||||
|
INTERFACES="enp0s25 wlp3s0"
|
||||||
|
|
||||||
|
declare -A bytes
|
||||||
|
|
||||||
|
for interface in $INTERFACES; do
|
||||||
|
bytes[past_rx_$interface]="$(cat /sys/class/net/"$interface"/statistics/rx_bytes)"
|
||||||
|
bytes[past_tx_$interface]="$(cat /sys/class/net/"$interface"/statistics/tx_bytes)"
|
||||||
|
done
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
down=0
|
||||||
|
up=0
|
||||||
|
|
||||||
|
for interface in $INTERFACES; do
|
||||||
|
bytes[now_rx_$interface]="$(cat /sys/class/net/"$interface"/statistics/rx_bytes)"
|
||||||
|
bytes[now_tx_$interface]="$(cat /sys/class/net/"$interface"/statistics/tx_bytes)"
|
||||||
|
|
||||||
|
bytes_down=$((((${bytes[now_rx_$interface]} - ${bytes[past_rx_$interface]})) / INTERVAL))
|
||||||
|
bytes_up=$((((${bytes[now_tx_$interface]} - ${bytes[past_tx_$interface]})) / INTERVAL))
|
||||||
|
|
||||||
|
down=$(((( "$down" + "$bytes_down" ))))
|
||||||
|
up=$(((( "$up" + "$bytes_up" ))))
|
||||||
|
|
||||||
|
bytes[past_rx_$interface]=${bytes[now_rx_$interface]}
|
||||||
|
bytes[past_tx_$interface]=${bytes[now_tx_$interface]}
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Download: $(print_bytes $down) / Upload: $(print_bytes $up)"
|
||||||
|
# echo "Download: $(print_bit $down) / Upload: $(print_bit $up)"
|
||||||
|
|
||||||
|
sleep $INTERVAL
|
||||||
|
done
|
||||||
7
.local/bin/polybar_scripts/toggle_bluetooth.sh
Executable file
7
.local/bin/polybar_scripts/toggle_bluetooth.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
if [ $(bluetoothctl show | grep "Powered: yes" | wc -c) -eq 0 ]
|
||||||
|
then
|
||||||
|
bluetoothctl power on
|
||||||
|
else
|
||||||
|
bluetoothctl power off
|
||||||
|
fi
|
||||||
Loading…
x
Reference in New Issue
Block a user