fetch 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/bin/bash
  2. clear
  3. c=3 b=4
  4. for j in c b; do
  5. for i in {0..7}; do
  6. printf -v $j$i "%b" "\e[${!j}${i}m"
  7. done
  8. done
  9. user=$(whoami)
  10. host=$(hostname)
  11. memory=$(free -h)
  12. os=$(source /etc/os-release && echo $PRETTY_NAME)
  13. kernel=$(uname -sr)
  14. 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 \")"
  15. mem=$(free -m | sed -n 's/^Mem:\s\+[0-9]\+\s\+\([0-9]\+\)\s.\+/\1/p')
  16. pkgs="$(xbps-query -l | wc -l)"
  17. shell=$(echo "$SHELL" | awk -F/ '{for ( i=1; i <= NF; i++) sub(".", substr(toupper($i),1,1) , $i); print $NF}')
  18. colors=$(for i in {0..7}; do echo -en "\e[${1}$((30 + $i))m▁▁▁"; done)
  19. get_uptime() {
  20. # Uptime works by retrieving the data in total seconds and then
  21. # converting that data into days, hours and minutes using simple
  22. # math.
  23. IFS=. read -r s _ </proc/uptime
  24. # Convert the uptime from seconds into days, hours and minutes.
  25. d=$((s / 60 / 60 / 24))
  26. h=$((s / 60 / 60 % 24))
  27. m=$((s / 60 % 60))
  28. # Only append days, hours and minutes if they're non-zero.
  29. case "$d" in [!0]*) uptime="${uptime}${d}d " ;; esac
  30. case "$h" in [!0]*) uptime="${uptime}${h}h " ;; esac
  31. case "$m" in [!0]*) uptime="${uptime}${m}m " ;; esac
  32. echo ${uptime:-0m}
  33. }
  34. init() {
  35. init=$(readlink /sbin/init)
  36. init=${init##*/}
  37. init=${init%%-*}
  38. export init
  39. }
  40. init
  41. cat <<EOF
  42. ${c0} ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
  43. ${c0} ▎▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▎ ${c2} ${c0} ${c3} ${c0}${c1}  ${c0}▎ ${c1}${c4}${c1} ${c4}$user@${c1}$host
  44. ${c0} ▎ ▎ ${c4}
  45. ${c0} ▎ ${c4}█▀▀▀▀▀▀▀▀▀█${c0} ▎ ${c4}OS ${c7} $os
  46. ${c0} ▎ ${c4}█ █${c0} ▎ ${c4}Kernel ${c7} $kernel
  47. ${c0} ▎ ${c4}█ █ █ █${c0} ▎ ${c4}WM ${c7} $wm
  48. ${c0} ▎ ${c0}█ █${c0} ▎ ${c4}Shell ${c7} $shell
  49. ${c0} ▎ ${c0}▀█▄▄▄▄▄▄▄█▀${c0} ▎ ${c4}Init ${c7} $init
  50. ${c0} ▎ ▎ ${c4}pkgs ${c7} $pkgs
  51. ${c0} ▎ ▎ ${c4}uptime ${c7} $(get_uptime)
  52. ${c0} ▎  ${c4}void  runit ^_^ ${c0} ▎ ${c4}memory ${c7} $mem $(echo / 3776MiB)
  53. ${c0} ▎▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▎ $colors
  54. EOF
  55. if [[ $1 == "-b" ]]; then
  56. for f in {0..6}; do
  57. echo -en "\033[$((f + 41))m\033[$((f + 30))m██▓▒░"
  58. done
  59. echo -en "\033[37m██\n"
  60. echo
  61. for f in {0..6}; do
  62. echo -en "\033[$((f + 41))m\033[1;$((f + 30))m██▓▒░"
  63. done
  64. echo -en "\033[1;37m██"
  65. echo -e "\033[0m"
  66. echo
  67. else
  68. :
  69. fi