2021-10-11 22:19:15 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
interval=0
|
2022-06-10 21:03:45 +02:00
|
|
|
interface="enp4s0"
|
2021-10-11 22:19:15 +02:00
|
|
|
|
|
|
|
datetime() {
|
|
|
|
icon=""
|
|
|
|
time="$(date "+%a, %d %b %H:%M")"
|
2022-01-21 00:42:52 +01:00
|
|
|
printf "^b#8FBCBB^^c#2E3440^ %s ^d^ %s" "$icon" "$time"
|
2021-10-11 22:19:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
battery() {
|
|
|
|
icon=""
|
|
|
|
battery="$(acpi | awk -F '[, :]' '{ print $6 }')" # without time
|
2022-01-21 00:42:52 +01:00
|
|
|
printf "^b#8FBCBB^^c#2E3440^ %s ^d^ %s" "$icon" "$battery"
|
2021-10-11 22:19:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cpu() {
|
|
|
|
icon=""
|
|
|
|
read cpu a b c previdle rest < /proc/stat
|
|
|
|
prevtotal=$((a+b+c+previdle))
|
|
|
|
sleep 0.5
|
|
|
|
read cpu a b c idle rest < /proc/stat
|
|
|
|
total=$((a+b+c+idle))
|
|
|
|
cpu=$((100*( (total-prevtotal) - (idle-previdle) ) / (total-prevtotal) ))
|
2022-01-21 00:42:52 +01:00
|
|
|
printf "^b#8FBCBB^^c#2E3440^ %s ^d^ %s" "$icon" "$cpu%"
|
2021-10-11 22:19:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
memory() {
|
|
|
|
icon=""
|
|
|
|
mem="$(free -h | awk '/^Mem/ { print $3"/"$2 }' | sed s/i//g)"
|
2022-01-21 00:42:52 +01:00
|
|
|
printf "^b#8FBCBB^^c#2E3440^ %s ^d^ %s" "$icon" "$mem"
|
2021-10-11 22:19:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
disk() {
|
|
|
|
icon=""
|
|
|
|
root="$(df / | awk '/^\// { print $5 }')"
|
|
|
|
home="$(df /home | awk '/^\// { print $5 }')"
|
2022-01-21 00:42:52 +01:00
|
|
|
printf "^b#8FBCBB^^c#2E3440^ %s ^d^ / %s | /home %s" "$icon" "$root" "$home"
|
2021-10-11 22:19:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
networkspeed() {
|
|
|
|
icon="龍"
|
|
|
|
up=""
|
|
|
|
down=""
|
2021-10-17 16:46:26 +02:00
|
|
|
R1="$(cat /sys/class/net/$interface/statistics/rx_bytes)"
|
|
|
|
T1="$(cat /sys/class/net/$interface/statistics/tx_bytes)"
|
2021-10-11 22:19:15 +02:00
|
|
|
sleep 1
|
2021-10-17 16:46:26 +02:00
|
|
|
R2="$(cat /sys/class/net/$interface/statistics/rx_bytes)"
|
|
|
|
T2="$(cat /sys/class/net/$interface/statistics/tx_bytes)"
|
2021-10-11 22:19:15 +02:00
|
|
|
TBPS="$(expr $T2 - $T1)"
|
|
|
|
RBPS="$(expr $R2 - $R1)"
|
|
|
|
TKBPS="$(expr $TBPS / 1024)"
|
|
|
|
RKBPS="$(expr $RBPS / 1024)"
|
2022-01-21 00:42:52 +01:00
|
|
|
printf "^b#8FBCBB^^c#2E3440^ %s ^d^ %s %skB/s %s %skB/s" "$icon" "$up" "$TKBPS" "$down" "$RKBPS"
|
2021-10-11 22:19:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
networkinfo() {
|
|
|
|
icon=""
|
2021-10-17 16:46:26 +02:00
|
|
|
IPADDR="$(ip a show dev $interface | awk '/inet / { print $2 } ')"
|
2022-01-21 00:42:52 +01:00
|
|
|
printf "^b#8FBCBB^^c#2E3440^ %s ^d^ %s [%s]" "$icon" "$interface" "$IPADDR"
|
2021-10-11 22:19:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
song() {
|
|
|
|
icon=""
|
|
|
|
song=$(playerctl --player=spotify,mpd metadata title)
|
|
|
|
artist=$(playerctl --player=spotify,mpd metadata artist)
|
2022-01-21 00:42:52 +01:00
|
|
|
printf "^b#8FBCBB^^c#2E3440^ %s ^d^ %s - %s" "$icon" "$artist" "$song"
|
2021-10-11 22:19:15 +02:00
|
|
|
}
|
|
|
|
|
2023-02-04 00:28:09 +01:00
|
|
|
updates() {
|
|
|
|
updates=$(checkupdates | wc -l)
|
|
|
|
icon=""
|
|
|
|
printf "^b#8FBCBB^^c#2E3440^ %s ^d^ %s" "$icon" "$updates"
|
|
|
|
}
|
|
|
|
|
2021-10-11 22:19:15 +02:00
|
|
|
while true; do
|
2023-02-04 00:28:09 +01:00
|
|
|
xsetroot -name " $(cpu) $(memory) $(networkspeed) $(networkinfo) $(disk) $(updates) $(song) $(datetime) "
|
2022-01-21 00:42:52 +01:00
|
|
|
sleep 8
|
2021-10-17 15:00:23 +02:00
|
|
|
done
|
|
|
|
|