-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathenv-info
executable file
·132 lines (110 loc) · 3.63 KB
/
env-info
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
#!/bin/bash
# simple screen information script
# similar to archey and screenfetch without annoying ASCII graphics
# this script is provided with NO GUARANTEE and NO SUPPORT
# if it breaks or does not do what you want, FIX IT YOURSELF
VERSION="cream-3.2" # updated for cream
# read wm names from a file
#WMLIST='/usr/bin/wmlist'
#wms=($(cat $WMLIST)) # read wmlist from file
# or use wm array -- add any that need to be recognized
wms=( 2bwm 2wm 9wm aewm afterstep alopex amiwm 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 olwm openbox oroborus pekwm ratpoison sapphire sawfish sithwm smallwm snapwm spectrwm stumpwm subtle tinywm tritium twm \
vtwm w9wm windowlab wm2 wmaker wmfs wmii wmx xfwm4 xmonad xoat )
# define colors for color-echo
red="\e[31m"
grn="\e[32m"
ylw="\e[33m"
cyn="\e[36m"
blu="\e[34m"
prp="\e[35m"
rst="\e[0m"
color-echo() { # print with colors
echo -e "$cyn$1: $rst$2"
}
print-kernel() {
color-echo 'Kernel' "$(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 "Uptime" $days'd '$hours'h '$mins'm'
}
print-shell() {
color-echo 'Shell' $SHELL
}
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 'CPU' "${cpu#*: }" # everything after colon is processor name
}
print-disk() {
# field 2 on line 2 is total, field 3 on line 2 is used
disk=$(df -h / | awk 'NR==2 {total=$2; used=$3; print used" / "total}')
color-echo 'Disk' "$disk"
}
print-mem() {
# field 2 on line 2 is total, field 3 on line 3 is used
# use -m because slackaware does not have -h
mem=$(free -m | awk 'NR==2 {total=$2} NR==3 {used=$3; print used"M / "total"M"}')
color-echo 'Mem' "$mem"
}
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-de() {
if [[ $(pgrep -x -u $USER lxsession) ]]; then # if lxsession is running, assume LXDE
color-echo 'DE' 'LXDE'
elif [ $(pgrep -x -u $USER xfce4-session) ]; then # if xfce4-session is running, assume Xfce
color-echo 'DE' 'Xfce'
fi
}
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
}
print-colors() {
NAMES=('black' 'red' 'green' 'yellow' 'blue' 'magenta' 'cyan' 'white')
for f in {0..7}; do
echo -en "\033[m\033[$(($f+30))m ${NAMES[$f]} " # normal colors
done
echo
for f in {0..7}; do
echo -en "\033[m\033[1;$(($f+30))m ${NAMES[$f]} " # bold colors
done
echo -e "$rst\n"
}
if [[ $1 = '-v' ]]; then # print version information and exit
echo $(basename "$0") / version: $VERSION / wm count: ${#wms[*]}
exit
fi
echo -e "\n$prp$USER@$HOSTNAME$rst\n"
print-distro
print-uptime
print-shell
print-de
print-wm
print-disk
print-mem
print-kernel
print-cpu
echo
print-colors