summaryrefslogblamecommitdiffstats
path: root/scripts/fetch
blob: a0381e6f0971f68fa2286e7d0eed6031d681d8bf (plain) (tree)












































































                                                                                                                                                              
#!/bin/bash
clear
c=3 b=4
for j in c b; do
  for i in {0..7}; do
    printf -v $j$i "%b" "\e[${!j}${i}m"
  done
done

user=$(whoami)
host=$(uname -a | awk '{print $2}')
memory=$(free -h)
os=$(source /etc/os-release && echo $PRETTY_NAME)
kernel=$(uname -sr)
wm="$(xprop -id $(xprop -root -notype | awk '$1=="_NET_SUPPORTING_WM_CHECK:"{print $5}') -notype -f _NET_WM_NAME 8t | grep "WM_NAME" | cut -f2 -d \")"
mem=$(free -m | sed -n 's/^Mem:\s\+[0-9]\+\s\+\([0-9]\+\)\s.\+/\1/p')
pkgs="$(xbps-query -l | wc -l)"
shell=$(echo "$SHELL" | awk -F/ '{for ( i=1; i <= NF; i++) sub(".", substr(toupper($i),1,1) , $i); print $NF}')
colors=$(for i in {0..7}; do echo -en "\e[${1}$((30 + $i))m▁▁▁"; done)

get_uptime() {
  # Uptime works by retrieving the data in total seconds and then
  # converting that data into days, hours and minutes using simple
  # math.
  IFS=. read -r s _ </proc/uptime

  # Convert the uptime from seconds into days, hours and minutes.
  d=$((s / 60 / 60 / 24))
  h=$((s / 60 / 60 % 24))
  m=$((s / 60 % 60))

  # Only append days, hours and minutes if they're non-zero.
  case "$d" in [!0]*) uptime="${uptime}${d}d " ;; esac
  case "$h" in [!0]*) uptime="${uptime}${h}h " ;; esac
  case "$m" in [!0]*) uptime="${uptime}${m}m " ;; esac

  echo ${uptime:-0m}
}

init() {
  init=$(readlink /sbin/init)
  init=${init##*/}
  init=${init%%-*}
  export init
}
init

cat <<EOF
${c0} ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
${c0} ▎▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▎ ${c2} ${c0} ${c3} ${c0}${c1}  ${c0}▎ ${c1}${c4}${c1} ${c4}$user@${c1}$host
${c0} ▎                            ▎ ${c4}
${c0} ▎        ${c4}█▀▀▀▀▀▀▀▀▀█${c0}         ▎ ${c4}OS     ${c7} $os
${c0} ▎        ${c4}█         █${c0}         ▎ ${c4}Kernel ${c7} $kernel
${c0} ▎        ${c4}█  █   █  █${c0}         ▎ ${c4}WM     ${c7} $wm
${c0} ▎        ${c0}█         █${c0}         ▎ ${c4}Shell  ${c7} $shell
${c0} ▎        ${c0}▀█▄▄▄▄▄▄▄█▀${c0}         ▎ ${c4}Init   ${c7} $init
${c0} ▎                            ▎ ${c4}pkgs   ${c7} $pkgs
${c0} ▎                            ▎ ${c4}uptime ${c7} $(get_uptime)
${c0} ▎   ${c4}void    runit ^_^    ${c0} ▎ ${c4}memory ${c7} $mem $(echo / 3776MiB)
${c0} ▎▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▎ $colors
EOF

if [[ $1 == "-b" ]]; then
  for f in {0..6}; do
    echo -en "\033[$((f + 41))m\033[$((f + 30))m██▓▒░"
  done
  echo -en "\033[37m██\n"
  echo
  for f in {0..6}; do
    echo -en "\033[$((f + 41))m\033[1;$((f + 30))m██▓▒░"
  done
  echo -en "\033[1;37m██"
  echo -e "\033[0m"
  echo
else
  :
fi