skynet/scripts/swaystatus.sh

60 lines
1.4 KiB
Bash
Raw Normal View History

2024-05-15 13:34:29 -05:00
#!/usr/bin/env bash
2024-06-13 21:40:54 -05:00
c_dark="#181825"
2024-06-18 16:22:32 -05:00
c_sep="#45475a"
c_bar="#cba6f7"
2024-06-13 21:40:54 -05:00
c_on="#a6e3a1"
c_off="#f38ba8"
2024-06-18 16:22:32 -05:00
c_icon="#89b4fa"
separator="<span foreground='$c_sep'></span>"
2024-06-13 21:40:54 -05:00
print_stat() {
icon=$1
content=$2
if [ "$icon" = "░" ]; then
2024-06-18 16:22:32 -05:00
icon='▁'
2024-05-15 13:34:29 -05:00
fi
2024-08-29 17:55:25 -05:00
echo -n "<span font_family='Symbols Nerd Font' background='$c_dark' foreground='$c_bar'>$icon</span>"
2024-06-13 21:40:54 -05:00
printf "%3d%%" "$content"
}
print_icon() {
icon=$1
2024-08-29 17:55:25 -05:00
echo -n "<span font_family='Symbols Nerd Font' foreground='$c_icon'>$icon</span> "
2024-06-13 21:40:54 -05:00
}
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=$(
2024-06-18 16:22:32 -05:00
print_icon "󰔠"
echo -n "$timew"
echo -n " $separator "
2024-06-13 21:40:54 -05:00
print_icon ""
print_stat "${cpu[0]}" "${cpu[1]}"
echo -n " $separator "
2024-08-29 17:55:25 -05:00
print_icon ""
2024-06-13 21:40:54 -05:00
print_stat "${ram[0]}" "${ram[1]}"
echo -n " $separator "
2024-06-18 16:22:32 -05:00
print_icon ""
2024-06-13 21:40:54 -05:00
print_stat "${disk1[0]}" "${disk1[1]}"
echo -n ' '
print_stat "${disk2[0]}" "${disk2[1]}"
2024-06-18 16:22:32 -05:00
echo -n " $separator <span foreground='$c_icon'></span> $clock $separator"
2024-05-15 13:34:29 -05:00
)
2024-06-13 21:40:54 -05:00
2024-05-15 13:34:29 -05:00
echo "$status"