commit 0b62ca178dcdeb54cce9c639ba051fc473a48890 Author: yutent Date: Fri Jan 5 19:00:07 2024 +0800 update diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..92b9750 --- /dev/null +++ b/debian/control @@ -0,0 +1,15 @@ +Package: afetch +Version: 1.0.0 +Section: utils +Architecture: all +Maintainer: Yutent +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. + diff --git a/src/fetch b/src/fetch new file mode 100755 index 0000000..62339ed --- /dev/null +++ b/src/fetch @@ -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 <