summaryrefslogtreecommitdiffstats
path: root/scripts/fetch
blob: a0381e6f0971f68fa2286e7d0eed6031d681d8bf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/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