88 lines
2.8 KiB
Bash
Executable File
88 lines
2.8 KiB
Bash
Executable File
#!/bin/sh
|
|
set -euf
|
|
|
|
COLORS="178 245 36 163 239 15"
|
|
ASCIIART="$XDG_CONFIG_HOME/neofetch/avali"
|
|
GAP=2
|
|
|
|
system_info() {
|
|
# use the function "iprint" for everything
|
|
# use $(col x) to get an arbitrary 0-255 color
|
|
# use $(bold) to bold, $(res) to reset formatting
|
|
iprint "$(col 10)$(bold)${USER}$(res)$(col 15)@$(bold)$(col 10)$(uname -n)"
|
|
iprint "$(col 7)$(bold)--------------"
|
|
iprint "$(col 15)$(bold)OS:$(res)$(col 10) Void Linux"
|
|
iprint "$(col 15)$(bold)Kernel:$(res)$(col 11) $(uname -r)"
|
|
iprint "$(col 15)$(bold)Shell:$(res)$(col 13) ${SHELL##*/}"
|
|
iprint "$(col 15)$(bold)WM:$(res)$(col 7) awesome"
|
|
iprint "$(col 15)$(bold)Terminal:$(res)$(col 7) urxvt"
|
|
# iprint "$(col 15)$(bold)CPU:$(res)$(col 7) $(cat /proc/cpuinfo | grep -i '^model name' | sort -u | sed -r 's/^model name\t: (.+)/\1/')"
|
|
iprint "$(col 15)$(bold)Packages:$(res)$(col 7) $(xbps-query -l | rg -c .)"
|
|
iprint "$(col 15)$(bold)Uptime:$(res)$(col 7) $(uptime -p | cut -d ' ' -f 2-)"
|
|
iprint "$(col 15)$(bold)Song:$(res)$(col 7) $(mpc -f '%artist% - %title%' current)"
|
|
iprint "$(col 7)$(bold)--------------"
|
|
iprint ""
|
|
iprint "$(col 0)███$(col 1)███$(col 2)███$(col 3)███$(col 4)███$(col 5)███$(col 6)███$(col 7)███"
|
|
iprint "$(col 8)███$(col 9)███$(col 10)███$(col 11)███$(col 12)███$(col 13)███$(col 14)███$(col 15)███"
|
|
}
|
|
|
|
# <-+-+-+-+-+- CONFIGURATION ENDS -+-+-+-+-+-> #
|
|
|
|
colres='\033[m'
|
|
|
|
process_colors() {
|
|
# colindex=1
|
|
# while IFS=" " read -r curcol; do
|
|
# colesc="$(tput setaf "$curcol")"
|
|
# c$colindex="$colesc"
|
|
# colindex="$(($colindex + 1))"
|
|
# done <<-EOF
|
|
# "$COLORS"
|
|
# EOF
|
|
c1="$(printf '%b\033[38;5;%sm' "$colres" "$1")"
|
|
c2="$(printf '%b\033[38;5;%sm' "$colres" "$2")"
|
|
c3="$(printf '%b\033[38;5;%sm' "$colres" "$3")"
|
|
c4="$(printf '%b\033[38;5;%sm' "$colres" "$4")"
|
|
c5="$(printf '%b\033[38;5;%sm' "$colres" "$5")"
|
|
c6="$(printf '%b\033[38;5;%sm' "$colres" "$6")"
|
|
}
|
|
|
|
process_ascii() {
|
|
# get maximum line length
|
|
maxlen="$(sed -e 's/\${c[1-6]}//g' "$ASCIIART" | wc -L)"
|
|
linecount="$(grep -c '^' "$ASCIIART")"
|
|
|
|
# actually do color replacement
|
|
final_ascii="$(sed \
|
|
-e "s/\${c1}/$c1/g" \
|
|
-e "s/\${c2}/$c2/g" \
|
|
-e "s/\${c3}/$c3/g" \
|
|
-e "s/\${c4}/$c4/g" \
|
|
-e "s/\${c5}/$c5/g" \
|
|
-e "s/\${c6}/$c6/g" \
|
|
"$ASCIIART")"
|
|
|
|
info_padding=$((GAP+maxlen))
|
|
}
|
|
|
|
col() { printf "\033[38;5;%sm" "$1"; }
|
|
bold() { printf '\033[1m'; }
|
|
res() { printf '\033[0m'; }
|
|
# reset formatting, move to padding, print line
|
|
iprint() { printf "%b%s\n" "\033[0m\033[${info_padding}C" "$1"; }
|
|
|
|
print_all() {
|
|
tput rmam # disable line wrapping
|
|
printf '%s\n' "$final_ascii"
|
|
printf '\0337 \033[?25l' # save cursor pos & hide it
|
|
printf "\033[%sF" "$linecount" #
|
|
system_info
|
|
tput smam # enable line wrapping
|
|
printf '\0338\n\033[?25h' # restore cursor pos & unhide it
|
|
}
|
|
|
|
set -f -- $COLORS && set +f
|
|
process_colors "$@"
|
|
process_ascii
|
|
print_all
|