Add polybar scripts

This commit is contained in:
Marty Oehme 2019-12-02 19:01:58 +01:00
parent a5d4ec5e4a
commit 9b4dd143f7
4 changed files with 106 additions and 5 deletions

View file

@ -51,10 +51,9 @@ bottom=false
width = 100%
height = 25
offset-x = 5%
offset-y = 2%
padding-left =
padding-right =
offset-y = 5%
padding-left = 0
padding-right = 0
module-margin-left = 2
modules-left = workspaces
@ -62,7 +61,7 @@ modules-center =
modules-right = networkspeed archupdates cpu temp date
tray-position = right
; Colors, defined further up
; Basic Colors, defined further up
background = ${colors.background}
foreground = ${colors.foreground}
line-size = 2

View file

@ -0,0 +1,21 @@
#!/bin/sh
if ! updates_arch=$(yay -Qun 2>/dev/null | wc -l); then
updates_arch=0
fi
if ! updates_aur=$(yay -Qum 2>/dev/null | wc -l); then
# if ! updates_aur=$(cower -u 2> /dev/null | wc -l); then
# if ! updates_aur=$(trizen -Su --aur --quiet | wc -l); then
# if ! updates_aur=$(pikaur -Qua 2> /dev/null | wc -l); then
# if ! updates_aur=$(rua upgrade --printonly 2> /dev/null | wc -l); then
updates_aur=0
fi
updates=$(("$updates_arch" + "$updates_aur"))
if [ "$updates" -gt 0 ]; then
echo "$updates"
else
echo ""
fi

14
.local/bin/polybar/poly-launch Executable file
View file

@ -0,0 +1,14 @@
#!/usr/bin/env bash
# Terminate already running bar instances
killall -q polybar
# Wait until the processes have been shut down
while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done
# Launch bar1 and bar2
echo "---" | tee -a /tmp/polybar1.log /tmp/polybar2.log
polybar mine >>/tmp/polybar1.log 2>&1 &
# polybar bar2 >>/tmp/polybar2.log 2>&1 &
echo "Polybar launched..."

View file

@ -0,0 +1,67 @@
#!/bin/bash
INTERVAL=3
INTERFACES="enp6s0 wlp0s29u1u1"
print_bytes() {
if [ "$1" -eq 0 ] || [ "$1" -lt 1000 ]; then
bytes="0"
elif [ "$1" -lt 1000000 ]; then
bytes="$(echo "scale=0;$1/1000" | bc -l)k"
else
bytes="$(echo "scale=1;$1/1000000" | bc -l)M"
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"
}
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
if [ "$down" -gt 1000 ] || [ "$up" -gt 1000 ]; then
echo " $(print_bytes $down) 祝$(print_bytes $up)"
else
echo ""
fi
# echo "Download: $(print_bytes $down) / Upload: $(print_bytes $up)"
# echo "Download: $(print_bit $down) / Upload: $(print_bit $up)"
sleep $INTERVAL
done