-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsysfetch
executable file
·122 lines (101 loc) · 3.08 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
#!/usr/bin/env bash
# sysfetch
# Thanks to u/x_ero for his sysinfo script
# Modified by gh0stzk
# 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)
packages=$(pacman -Q | 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 / | awk 'NR == 2 { print $1 }')
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" " Hi $CRE$CBD$name$CNC"
printf "%s%b\n" "$PADC" " 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${packages}\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 " %s\n" "$CNC"
# 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 '%s' "$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