update
commit
0b62ca178d
|
@ -0,0 +1,15 @@
|
|||
Package: afetch
|
||||
Version: 1.0.0
|
||||
Section: utils
|
||||
Architecture: all
|
||||
Maintainer: Yutent <yutent.io@gmail.com>
|
||||
Author: Yutent
|
||||
Installed-Size: ${size}
|
||||
Priority: optional
|
||||
Breaks: neofetch
|
||||
Replaces: neofetch
|
||||
Provides: neofetch
|
||||
Homepage: https://git.wkit.fun/appcat/afetch
|
||||
Description: Another neofetch, only for debian.
|
||||
Another neofetch, only for debian.
|
||||
|
|
@ -0,0 +1,175 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
# 颜色定义
|
||||
_cbk=$(tput setaf 0) # 黑色
|
||||
_cre=$(tput setaf 1) # 红色
|
||||
_cgr=$(tput setaf 2) # 绿色
|
||||
_cye=$(tput setaf 3) # 黄色
|
||||
_cbl=$(tput setaf 4) # 蓝色
|
||||
_cma=$(tput setaf 5) # 紫色
|
||||
_ccy=$(tput setaf 6) # 青色
|
||||
_cwh=$(tput setaf 7) # 白色
|
||||
|
||||
_cbd=$(tput bold) # 加粗
|
||||
_cnc=$(tput sgr0) # 重置(结束)
|
||||
|
||||
# vars
|
||||
FULL=▓
|
||||
EMPTY=░
|
||||
|
||||
|
||||
name=$USER
|
||||
host=$(uname -n)
|
||||
distro=$(uname -o | awk -F '"' '/PRETTY_NAME/ { print $2 }' /etc/os-release)
|
||||
packages=$(apt list --installed | wc -l)
|
||||
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 \")
|
||||
storage=$(df -h --output=used,size / | awk 'NR == 2 { print $1,"/",$2 }')
|
||||
term=$(ps -o sid= -p "$$" | xargs ps -o ppid= -p | xargs ps -o comm= -p)
|
||||
uptm=$(uptime -p | sed -e 's/up //')
|
||||
|
||||
|
||||
# 获取设备信息
|
||||
get_model() {
|
||||
if [[ -d /system/app/ && -d /system/priv-app ]]; then
|
||||
model="$(getprop ro.product.brand) $(getprop ro.product.model)"
|
||||
|
||||
elif [[ -f /sys/devices/virtual/dmi/id/product_name || -f /sys/devices/virtual/dmi/id/product_version ]]; then
|
||||
model=$(< /sys/devices/virtual/dmi/id/product_name)
|
||||
model+=" $(< /sys/devices/virtual/dmi/id/product_version)"
|
||||
|
||||
elif [[ -f /sys/firmware/devicetree/base/model ]]; then
|
||||
model=$(< /sys/firmware/devicetree/base/model)
|
||||
|
||||
elif [[ -f /tmp/sysinfo/model ]]; then
|
||||
model=$(< /tmp/sysinfo/model)
|
||||
fi
|
||||
}
|
||||
|
||||
# 获取debian的内核版本
|
||||
get_kernel() {
|
||||
IFS=" " read -ra kver <<< "$(uname -v)"
|
||||
kernel_version="${kver[4]}-amd64"
|
||||
}
|
||||
|
||||
get_shell(){
|
||||
shell_name=${SHELL##*/}
|
||||
shell_version=" "
|
||||
|
||||
case $shell_name in
|
||||
bash)
|
||||
shell_version=${BASH_VERSION/-*}
|
||||
;;
|
||||
|
||||
sh|ash|dash|es)
|
||||
;;
|
||||
|
||||
*)
|
||||
shell_version=$("$shell_name" --version 2>&1)
|
||||
;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
# progress bar
|
||||
draw() {
|
||||
perc=$1
|
||||
size=$2
|
||||
inc=$((perc * size / 100))
|
||||
out=
|
||||
color="$3"
|
||||
for v in $(seq 0 $((size - 1))); do
|
||||
test "$v" -le "$inc" &&
|
||||
out="${out}\e[1;${color}m${FULL}" ||
|
||||
out="${out}\e[0;37m${CWH}${EMPTY}"
|
||||
done
|
||||
printf "$out"
|
||||
}
|
||||
|
||||
# 清屏
|
||||
clear
|
||||
|
||||
# find the center of the screen
|
||||
COL=$(tput cols)
|
||||
ROW=$(tput lines)
|
||||
((PADY = ROW / 2 - 10 - 22 / 2))
|
||||
((PADX = COL / 2 - 34 / 2))
|
||||
|
||||
for ((i = 0; i < PADX; ++i)); do
|
||||
PADC="$PADC "
|
||||
done
|
||||
|
||||
for ((i = 0; i < PADY; ++i)); do
|
||||
PADR="$PADR\n"
|
||||
done
|
||||
|
||||
get_model
|
||||
get_kernel
|
||||
get_shell
|
||||
|
||||
ram=$(free | awk '/Mem:/ {print int($3/$2 * 100.0)}')
|
||||
|
||||
# vertical padding
|
||||
printf "%b" "$PADR"
|
||||
printf "\n"
|
||||
|
||||
PADXX=$((PADX - 3))
|
||||
for ((i = 0; i < PADXX; ++i)); do
|
||||
PADCC="$PADCC "
|
||||
done
|
||||
|
||||
# Ascii art arms
|
||||
cat <<EOF
|
||||
${_cwh} _,met\$\$\$\$\$gg.
|
||||
,g\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$P.
|
||||
,g\$\$P" """Y\$\$.".
|
||||
,\$\$P' \`\$\$\$.
|
||||
',\$\$P ,ggs. \`\$\$b:
|
||||
\`d\$\$' ,\$P"' ${_cre}.${_cwh} \$\$\$
|
||||
\$\$P d\$' ${_cre},${_cwh} \$\$P
|
||||
\$\$: \$\$. ${_cre}-${_cwh} ,d\$\$'
|
||||
\$\$; Y\$b._ _,d\$P'
|
||||
Y\$\$. ${_cre}\`.${_cwh}\`"Y\$\$\$\$P"'
|
||||
${_cwh} \`\$\$b ${_cre}"-.__
|
||||
${_cwh} \`Y\$\$
|
||||
\`Y\$\$.
|
||||
\`\$\$b.
|
||||
\`Y\$\$b.
|
||||
\`"Y\$b._
|
||||
\`"""
|
||||
EOF
|
||||
|
||||
|
||||
|
||||
BAR1=" ▓▓▓▒▒▒"
|
||||
BAR2=" ▓▓▓░░░"
|
||||
OUTT1="$_cbk$BAR1${_cre}$BAR1${_cgr}$BAR1${_cye}$BAR1${_cbl}$BAR1${_cma}$BAR1${_ccy}$BAR1${_cwh}$BAR1${_cnc}"
|
||||
OUTT2="$_cbk$BAR2${_cre}$BAR2${_cgr}$BAR2${_cye}$BAR2${_cbl}$BAR2${_cma}$BAR2${_ccy}$BAR2${_cwh}$BAR2${_cnc}"
|
||||
printf "%b\n" "$OUTT1"
|
||||
printf "%b\n\n" "$OUTT2"
|
||||
|
||||
|
||||
# greetings
|
||||
printf "%b" " Hi ${_cre}${_cbd}${name}@${host}${_cnc}\n"
|
||||
printf "%b" " Uptime ${_ccy}${_cbd}$uptm${_cnc}\n\n"
|
||||
|
||||
# environment
|
||||
printf "%b" "${_cre} OS ${_cwh} ⏹ ${_cnc}$distro\n"
|
||||
printf "%b" "${_cre} Host ${_cwh} ⏹ ${_cnc}${model}\n"
|
||||
printf "%b" "${_cbl} Kernel ${_cwh} ⏹ ${_cnc}${kernel_version}\n"
|
||||
printf "%b" "${_cma} Packages ${_cwh} ⏹ ${_cnc}${packages} (apt)\n"
|
||||
printf "%b" "${_cgr} Shell ${_cwh} ⏹ ${_cnc}${shell_name} ${shell_version}\n"
|
||||
printf "%b" "${_cye} Terminal ${_cwh} ⏹ ${_cnc}${term}\n"
|
||||
printf "%b" "${_ccy} WM ${_cwh} ⏹ ${_cnc}${wm}\n"
|
||||
printf "%b" "${_cbl} Disk ${_cwh} ⏹ ${_cnc}${storage}\n"
|
||||
printf "%b" "${_cbl} Memery ${_cwh} ⏹ ${_cnc}$(draw "$ram" 15 35) ${ram}%\n"
|
||||
printf "\n" "${_cnc}"
|
||||
|
||||
|
||||
|
||||
# hide the cursor and wait for user input
|
||||
tput civis
|
||||
read -n 1
|
||||
|
||||
# give the cursor back
|
||||
tput cnorm
|
Loading…
Reference in New Issue