skynet/scripts/swaystatus.sh

60 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
c_dark="#181825"
c_sep="#45475a"
c_bar="#cba6f7"
c_on="#a6e3a1"
c_off="#f38ba8"
c_icon="#89b4fa"
separator="<span foreground='$c_sep'></span>"
print_stat() {
icon=$1
content=$2
if [ "$icon" = "░" ]; then
icon='▁'
fi
echo -n "<span background='$c_dark' foreground='$c_bar'>$icon</span>"
printf "%3d%%" "$content"
}
print_icon() {
icon=$1
echo -n "<span foreground='$c_icon'>$icon</span> "
}
read -r -d '' -a cpu < <(sicli -i cpu -p0)
read -r -d '' -a ram < <(sicli -i memory -p0)
read -r -d '' -a disk1 < <(sicli -i disk -p0 -r /)
read -r -d '' -a disk2 < <(sicli -i disk -p0 -r /home)
timew="$(timew summary | tail -n2 | head -n1 | awk '{ print $1 }' | sed 's/:[0-9]\+$//')"
if [ "$timew" = "No" ]; then
timew="0:00"
fi
if [ "$(timew get dom.active)" = "1" ]; then
timew="<span foreground='$c_on'>+$timew</span>"
else
timew="<span foreground='$c_off'>-$timew</span>"
fi
clock=$(date +'%a %b %d %H:%M')
status=$(
print_icon "󰔠"
echo -n "$timew"
echo -n " $separator "
print_icon ""
print_stat "${cpu[0]}" "${cpu[1]}"
echo -n " $separator "
print_icon ""
print_stat "${ram[0]}" "${ram[1]}"
echo -n " $separator "
print_icon ""
print_stat "${disk1[0]}" "${disk1[1]}"
echo -n ' '
print_stat "${disk2[0]}" "${disk2[1]}"
echo -n " $separator <span foreground='$c_icon'></span> $clock $separator"
)
echo "$status"