-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathshow_info.sh
99 lines (84 loc) · 2.57 KB
/
show_info.sh
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
#!/bin/bash
clear
# or use wm array -- add any that need to be recognized
wms=( 2bwm 2wm 9wm aewm afterstep ahwm alopex amiwm antiwm awesome blackbox bspwm catwm clfswm ctwm cwm dminiwm dragonflywm dwm echinus \
euclid-wm evilpoison evilwm fluxbox flwm fvwm-crystal goomwwm hcwm herbstluftwm i3 icewm jwm karmen larswm lwm matwm2 mcwm monsterwm \
musca notion nwm olwm openbox oroborus pekwm ratpoison sapphire sawfish sscrotwm sithwm smallwm snapwm spectrwm stumpwm subtle tfwm tinywm tritium twm \
uwm vtwm w9wm weewm wind windowlab wm2 wmaker wmfs wmii wmx xfwm4 xmonad xoat yeahwm )
# define colors for color-echo
red="\e[31m"
grn="\e[32m"
ylw="\e[33m"
cyn="\e[36m"
blu="\e[34m"
prp="\e[35m"
bprp="\e[35;1m"
rst="\e[0m"
color-echo()
{ # print with colors
echo -e " $red$1: $rst$2"
}
print-kernel()
{
color-echo 'KL' "$(uname -smr)"
}
print-uptime()
{
up=$(</proc/uptime)
up=${up//.*} # string before first . is seconds
days=$((${up}/86400)) # seconds divided by 86400 is days
hours=$((${up}/3600%24)) # seconds divided by 3600 mod 24 is hours
mins=$((${up}/60%60)) # seconds divided by 60 mod 60 is mins
color-echo "UP" $days'd '$hours'h '$mins'm'
}
print-shell() {
color-echo 'SH' "$(echo "$SHELL" | awk -F/ '{for ( i=1; i <= NF; i++) sub(".", substr(toupper($i),1,1) , $i); print $NF}')"
}
print-cpu()
{
arm=$(grep ARM /proc/cpuinfo) # ARM procinfo uses different format
if [[ "$arm" != "" ]]; then
cpu=$(grep -m1 -i 'Processor' /proc/cpuinfo)
else
cpu=$(grep -m1 -i 'model name' /proc/cpuinfo)
fi
color-echo 'CP' "${cpu#*: }" # everything after colon is processor name
}
print-gpu()
{
gpu=$(lspci | grep VGA | awk -F ': ' '{print $2}' | sed 's/(rev ..)//g')
color-echo 'GP' "$gpu"
}
print-packages()
{
packages=$(dpkg --get-selections | grep -v "deinstall" | wc -l)
color-echo 'PKG' "$packages"
}
print-wm()
{
for wm in ${wms[@]}; do # pgrep through wmname array
pid=$(pgrep -x -u $USER $wm) # if found, this wmname has running process
if [[ "$pid" ]]; then
color-echo 'WM' $wm
break
fi
done
}
print-distro()
{
[[ -e /etc/os-release ]] && source /etc/os-release
if [[ -n "$PRETTY_NAME" ]]; then
color-echo 'OS' "$PRETTY_NAME"
else
color-echo 'OS' "not found"
fi
}
echo
echo -en " █▀▀▀▀▀▀▀▀█ | " && print-distro
echo -en " █ █ | " && print-wm
echo -en " █ █ █ █ | " && print-uptime
echo -en " █ █ | " && print-shell
echo -en " ▀█▄▄▄▄▄▄█▀ | " && print-cpu
echo
echo
#print-colors