-
Notifications
You must be signed in to change notification settings - Fork 0
/
sysinfo.bak
executable file
·211 lines (188 loc) · 11.8 KB
/
sysinfo.bak
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/bin/sh
### Variables ###
version="1.0"
date=$(date)
user=$(whoami)
hostname=$(/bin/cat /etc/hostname)
shell=$(echo $SHELL)
a=$(/bin/cat /sys/devices/virtual/dmi/id/board_vendor)
b=$(/bin/cat /sys/devices/virtual/dmi/id/board_name)
mem=$(free -h | awk '/^Mem:/ {print $3 "/" $2}')
mem_percentage=$(free | awk '/Mem/{printf("Mem used: %.1f%"), $3/($2+.000000001)*100} /buffers\/cache/{printf(", buffers: %.1f%"), $4/($3+$4)+.000000001*100}')
swap=$(free -h | awk '/^Swap:/ {print $3 "/" $2}')
swap_percentage=$(free | awk '/Swap/{printf("swap: %.1f%"), $3/($2+.000000001)*100}')
[ $(command -v "sensors") ] && cpu_temp=$(sensors | awk '/^CPU/ {print $2}')
cpu=$(echo "CPU Usage: "$(top -bn1 | awk '/Cpu/ { print $2}')"%")
cpu_name=$(lscpu | awk '/^Model name/{print $3 " " $4 " " $5 " " $6 " " $7 " " $8}')
architecture=$(uname -m)
[ -d /sys/class/power_supply ] && battery_capacity=$(cat /sys/class/power_supply/BAT0/capacity) && battery_status=$(cat /sys/class/power_supply/BAT0/status)
kernel=$(uname -r)
uptime=$(uptime --pretty | sed -e 's/up //g' -e 's/ days/d/g' -e 's/day/d/g' -e 's/ hours/h/g' -e 's/ hour/h/g' -e 's/ minutes/m/g' -e 's/, / /g')
gpu=$(lspci | grep ' VGA ' | cut -d" " -f 1 | xargs -i lspci -v -s {} | awk '/Subsystem/ {print $3 " " $ 4 " " $5 $6}')
os=$(lsb_release -a | awk '/^Description/ {print $2,$3}')
### Functions ###
usage()
{
printf "%s" "
Usage: sysinfo <args>
-h, --help Prints this help page
-a, --arch Print Arch ascii logo
-u, --ubuntu Print Ubuntu ascii logo
-g, --gentoo Print Gentoo ascii logo
-v, --void Print Void ascii logo
-d, --debian Print Debian ascii logo
-V, --version Prints the current Sysinfo version
"
exit 1
}
arch()
{
pkg=$(pacman -Q | wc -l)
echo ""
printf "\033[0;35m $user\033[0m@\033[0;36m$hostname\033[0m\n"
echo " ---------------------------------------------------------------------"
printf " \033[0;36m | Date | $date\033\n[0m"
printf " \033[0;34m | OS | $os\033\n[0m"
printf " \033[0;36m /\ \033[0;32m | Kernel | $kernel\033\n[0m"
printf " \033[0;36m / \ \033[0;35m | Uptime | $uptime\033\n[0m"
printf " \033[0;36m /\ \ \033[0;31m | User | $user\033\n[0m"
printf " \033[0;36m / > ω <\ \033[0;34m | >_ Shell | $shell\033\n[0m"
printf " \033[0m / __ \ \033[0;36m | Packages | $pkg\033\n[0m"
echo -e " \033[0m / __| |__-\ \033[0m | CPU | $cpu_name \033[0;31m'$architecture'\033[0m"
printf " \033[0m /_-'' ''-_\ \033[00;35m| GPU | $gpu \033\n[0m"
echo -e " \033[0;31m | MemInfo | $mem Mem, $mem_percentage\033[0m"
echo -e " \033[0;34m | CpuInfo | $cpu $cpu_temp\033[0m"
echo -e " \033[0;36m | Motherboard | $a $b\033[0m"
echo -e " \033[0;35m | SwapInfo | $swap Swap, $swap_percentage\033[0m"
echo -e " \033[0;33m | Battery | $battery_capacity% $battery_status\033[0m"
echo " ---------------------------------------------------------------------"
}
ubuntu()
{
pkg=$(apt list --installed | wc -l)
echo ""
printf "\033[0;35m $user\033[0m@\033[0;36m$hostname\033[0m\n"
echo " ---------------------------------------------------------------------"
printf " \033[0;36m | Date | $date\033\n[0m"
printf " \033[0;34m | OS | $os\033\n[0m"
printf " \033[0;31m _ \033[0;32m | Kernel | $kernel\033\n[0m"
printf " \033[1;31m ◣__(_)◢ \033[0;35m | Uptime | $uptime\033\n[0m"
printf " \033[1;31m _/ --- \ \033[0;31m | User | $user\033\n[0m"
printf " \033[1;31m (_) |>ω<| | \033[0;34m | >_ Shell | $shell\033\n[0m"
printf " \033[1;31m \ --- _/ \033[0;36m | Packages | $pkg\033\n[0m"
echo -e " \033[1;31m C__/---(_) \033[0m | CPU | $cpu_name \033[0;31m'$architecture'\033[0m"
printf " \033[00;35m| GPU | $gpu \033\n[0m"
echo -e " \033[0;31m | MemInfo | $mem Mem, $mem_percentage\033[0m"
echo -e " \033[0;34m | CpuInfo | $cpu $cpu_temp\033[0m"
echo -e " \033[0;36m | Motherboard | $a $b\033[0m"
echo -e " \033[0;35m | SwapInfo | $swap Swap, $swap_percentage\033[0m"
echo -e " \033[0;33m | Battery | $battery_capacity% $battery_status\033[0m"
echo " ---------------------------------------------------------------------"
}
gentoo()
{
#pkg=$(ls /var/db/pkg/* | wc -l)
echo ""
printf "\033[0;35m $user\033[0m@\033[0;36m$hostname\033[0m\n"
echo " ---------------------------------------------------------------------"
printf " \033[0;36m | Date | $date\033\n[0m"
printf " \033[0;34m | OS | $os\033\n[0m"
printf " \033[0;35m _-----_ \033[0;32m | Kernel | $kernel\033\n[0m"
printf " \033[1;35m ( \\ \033[0;35m | Uptime | $uptime\033\n[0m"
printf " \033[1;35m \\ OωO \\ \033[0;31m | User | $user\033\n[0m"
printf " \033[1;35m \\ ) \033[0;34m | >_ Shell | $shell\033\n[0m"
printf " \033[0m / _/ \033[0;36m | Packages | $pkg\033\n[0m"
echo -e " \033[0m ( _- \033[0m | CPU | $cpu_name \033[0;31m'$architecture'\033[0m"
printf " \033[0m \\_____- \033[0;35m| GPU | $gpu \033\n[0m"
echo -e " \033[0;31m | MemInfo | $mem Mem, $mem_percentage\033[0m"
echo -e " \033[0;34m | CpuInfo | $cpu $cpu_temp\033[0m"
echo -e " \033[0;36m | Motherboard | $a $b\033[0m"
echo -e " \033[0;35m | SwapInfo | $swap Swap, $swap_percentage\033[0m"
echo -e " \033[0;33m | Battery | $battery_capacity% $battery_status\033[0m"
echo " ---------------------------------------------------------------------"
}
void()
{
#pkg=$(xbps-query -m | wc -l)
echo ""
printf "\033[0;35m $user\033[0m@\033[0;36m$hostname\033[0m\n"
echo " --------------"
printf " \033[0;36m Date | $date\033\n[0m"
printf " \033[0;34m OS | $os\033\n[0m"
printf " \033[0;32m _ \033[0;32m Kernel | $kernel\033\n[0m"
printf " \033[1;32m |\_____/| \033[0;35m Uptime | $uptime\033\n[0m"
printf " \033[1;32m _\____ | \033[0;31m User | $user\033\n[0m"
printf " \033[1;32m | \ \ | \033[0;34m >_ Shell | $shell\033\n[0m"
printf " \033[1;32m | |\033[0m ÒωÓ\033[1;32m , \033[0;36m | Packages | $pkg\033\n[0m"
echo -e " \033[1;32m | \_____\_|-, | \033[0m CPU | $cpu_name \033[0;31m'$architecture'\033[0m"
printf " \033[1;32m -_______\ \_/ \033[00;35m GPU | $gpu \033\n[0m"
echo -e " \033[0;31m MemInfo | $mem Mem, $mem_percentage\033[0m"
echo -e " \033[0;34m CpuInfo | $cpu $cpu_temp\033[0m"
echo -e " \033[0;36m Motherboard | $a $b\033[0m"
echo -e " \033[0;35m SwapInfo | $swap Swap, $swap_percentage\033[0m"
echo -e " \033[0;33m Battery | $battery_capacity% $battery_status\033[0m"
echo " --------------"
}
debian()
{
pkg=$(apt list --installed | wc -l)
echo ""
printf "\033[0;35m $user\033[0m@\033[0;36m$hostname\033[0m\n"
echo " ---------------------------------------------------------------------"
printf " \033[0;36m | Date | $date\033\n[0m"
printf " \033[0;34m | OS | $os\033\n[0m"
printf " \033[0;31m ______ \033[0;32m | Kernel | $kernel\033\n[0m"
printf " \033[1;31m / ___ \ \033[0;35m | Uptime | $uptime\033\n[0m"
printf " \033[1;31m | / OωO | \033[0;31m | User | $user\033\n[0m"
printf " \033[1;31m | \____- \033[0;34m | >_ Shell | $shell\033\n[0m"
printf " \033[1;31m -_ \033[0;36m | Packages | $pkg\033\n[0m"
echo -e " \033[1;31m --_\ \033[0m | CPU | $cpu_name \033[0;31m'$architecture'\033[0m"
printf " \033[00;35m| GPU | $gpu \033\n[0m"
echo -e " \033[0;31m | MemInfo | $mem Mem, $mem_percentage\033[0m"
echo -e " \033[0;34m | CpuInfo | $cpu $cpu_temp\033[0m"
echo -e " \033[0;36m | Motherboard | $a $b\033[0m"
echo -e " \033[0;35m | SwapInfo | $swap Swap, $swap_percentage\033[0m"
echo -e " \033[0;33m | Battery | $battery_capacity% $battery_status\033[0m"
echo " ---------------------------------------------------------------------"
}
unknown()
{
#pkg=$(xbps-query -m | wc -l)
echo ""
printf "\033[0;35m $user\033[0m@\033[0;36m$hostname\033[0m\n"
echo " ---------------------------------------------------------------------"
printf " \033[0;36m | Date | $date\033\n[0m"
printf " \033[0;34m | OS | $os\033\n[0m"
printf " \033[0m ._.--._. \033[0;32m | Kernel | $kernel\033\n[0m"
printf " \033[0m \|>_< |/ \033[0;35m | Uptime | $uptime\033\n[0m"
printf " \033[0m |\033[1;33m:_/\033[0m | \033[0;31m | User | $user\033\n[0m"
printf " \033[0m // \ \ \033[0;31m? \033[0;34m | >_ Shell | $shell\033\n[0m"
printf " \033[0m (| | ) \033[0;31m/ \033[0;36m | Packages | $pkg\033\n[0m"
echo -e " \033[0;33m /;\_ _/;\- \033[0m | CPU | $cpu_name \033[0;31m'$architecture'\033[0m"
printf " \033[0;33m \___)=(___/ \033[00;35m| GPU | $gpu \033\n[0m"
echo -e " \033[0;31m | MemInfo | $mem Mem, $mem_percentage\033[0m"
echo -e " \033[0;34m | CpuInfo | $cpu $cpu_temp\033[0m"
echo -e " \033[0;36m | Motherboard | $a $b\033[0m"
echo -e " \033[0;35m | SwapInfo | $swap Swap, $swap_percentage\033[0m"
echo -e " \033[0;33m | Battery | $battery_capacity% $battery_status\033[0m"
echo " ---------------------------------------------------------------------"
}
#if [[ $1 == "-a" ]] || [[ $1 == "--arch" ]]; then
# arch
#if [[ $os == "Arch Linux" ]]; then
# arch
# exit 1
#elif [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
# usage
#fi
case "$1" in
"-a" | "--arch") arch ;;
"-g" | "--gentoo") gentoo ;;
"-v" | "--void") void ;;
"-d" | "--debian") debian;;
"-u" | "--ubuntu") ubuntu ;;
"-un"| "--unknown") unknown ;;
"-h" | "--help") usage ;;
"-V" | "--version") echo "Sysinfo version $version" ;;
*) printf "\033[1;33m Bye $user :) " ;;
esac