-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsysfetch
executable file
·149 lines (123 loc) · 3.89 KB
/
sysfetch
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/sh
# sysfetch
# Thanks to u/x_ero for his sysinfo script
# Modified by gh0stzk https://github.com/gh0stzk/dotfiles
# color escapes
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)
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 \")
get_pkg_count() {
package_managers=('xbps-install' 'apk' 'apt' 'pacman' 'nix' 'dnf' 'rpm' 'emerge')
for package_manager in ${package_managers[@]}; do
if command -v $package_manager 2>/dev/null>&2; then
case "$package_manager" in
xbps-install ) xbps-query -l | wc -l ;;
apk ) apk search | wc -l ;;
apt ) apt list --installed 2>/dev/null | wc -l ;;
pacman ) pacman -Q | wc -l ;;
nix ) nix-env -qa --installed '*' | wc -l ;;
dnf ) dnf list installed | wc -l ;;
rpm ) rpm -qa | wc -l ;;
emerge ) qlist -I | wc -l ;;
esac
# if a package manager is found return from the function
return
fi
done
echo 'Unknown'
}
storage=$(df -h / | awk '/^\//{print $3}')
term=$(ps -o sid= -p "$$" | xargs ps -o ppid= -p | xargs ps -o comm= -p)
uptm=$(uptime -p | sed -e 's/hour/hr/' -e 's/hours/hrs/' -e 's/minutes/mins/' -e 's/minute/min/' -e 's/up //')
#Cleanup first
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
# 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
$PADCC$CBD $CBL.
$PADCC $CBL/ $CMA\\
$PADCC $CBL/ $CMA\\
$PADCC $CBL/^. $CMA\\
$PADCC $CBL/ .$CWH-$CMA. \\
$PADCC $CBL/ ( $CMA) _\\
$PADCC $CBL/ _.~ $CMA~._^\\
$PADCC $CBL/.^ $CMA^.\\
EOF
BAR=" ▓▒░"
OUTT="$CBK$BAR$CRE$BAR$CGR$BAR$CYE$BAR$CBL$BAR$CMA$BAR$CCY$BAR$CWH$BAR$CNC"
printf "%s%b\n\n" "$PADC" "$OUTT"
# greetings
#printf "%s%b\n" "$PADC" " Welcome back, $CRE$CBD$name$CNC"
#printf "%s%b\n" "$PADC" " you're logged into $CGR$CBD$host$CNC"
#printf "%s%b\n\n" "$PADC" " been up $CCY$CBD$uptm$CNC"
printf "%s%b\n" "$PADC" " Hi, $CRE$CBD$name$CNC"
printf "%s%b\n" "$PADC" " and welcome to $CGR$CBD$host$CNC"
printf "%s%b\n\n" "$PADC" " up $CCY$CBD$uptm$CNC"
# environment
printf "%s%b" "$PADC" "$CRE distro $CWH⏹ $CNC$distro\n"
printf "%s%b" "$PADC" "$CBL kernel $CWH⏹ $CNC$(uname -r)\n"
#printf "%s%b" "$PADC" "$CMA packages $CWH⏹ $CNC$(get_pkg_count)\n"
#printf "%s%b" "$PADC" "$CGR shell $CWH⏹ $CNC${SHELL##*/}\n"
printf "%s%b" "$PADC" "$CYE term $CWH⏹ $CNC$term\n"
printf "%s%b" "$PADC" "$CCY wm $CWH⏹ $CNC${wm}\n"
printf "%s%b" "$PADC" "$CBL disk $CWH⏹ $CNC$storage used\n"
printf " $CNC\n"
# 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
}
# cpu
cpu=$(top -bn1 | grep "Cpu(s)" | awk '{print $2}' | cut -d'.' -f1)
c_lvl=`printf $cpu`
printf "%b" "$PADC"
printf " $CMA%-4s $CWH%-5s %-25s \n" " cpu" "$c_lvl%" $(draw $c_lvl 15 35)
# ram
ram=$(free | awk '/Mem:/ {print int($3/$2 * 100.0)}')
printf "%b" "$CNC" "$PADC"
printf " $CMA%-4s $CWH%-5s %-25s \n" " ram" "$ram%" $(draw $ram 15 35)
# hide the cursor and wait for user input
tput civis
read -n 1
# give the cursor back
tput cnorm