-
Notifications
You must be signed in to change notification settings - Fork 4
/
mhwd-tui
executable file
·244 lines (233 loc) · 6.75 KB
/
mhwd-tui
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#!/bin/bash
RED='\e[41m'
BLUE='\e[44m'
ORANGE='\e[46m'
NC='\e[0m'
trap 'rm $HOME/{.installed_kernels,.available_kernels}' EXIT
in_array() {
local haystack=${1}[@]
local needle=${2}
for i in ${!haystack}; do
if [[ ${i} == ${needle} ]]; then
return 0
fi
done
return 1
}
function install_kernel {
PS3="which kernel do you wish to install? (press ctrl+d to preceed, ctrl+c to cancel): "
# Gather the results in an array.
kernels=($(grep -v -f .installed_kernels .available_kernels) "proceed" "cancel")
select pick in "${kernels[@]}"
do
case $pick in
proceed)
break
;;
cancel)
exit
;;
*) if in_array picks $pick; then
picks=($(printf -- '%s\n' "${picks[@]}" | grep -v $pick));
else
picks+=("$pick")
fi
printf 'Selected: %s\n' "${picks[*]}"
;;
esac
done
if [[ $picks ]]; then
printf 'Installing %s\n' "${picks[*]}"
sudo mhwd-kernel -i "${picks[@]}"
fi
}
function remove_kernel {
PS3="which kernel do you wish to remove? (press ctrl+d to preceed, ctrl+c to cancel): "
# Gather the results in an array.
kernels=($(grep -v -f .running_kernel .installed_kernels) "proceed" "cancel")
select pick in "${kernels[@]}"
do
case $pick in
proceed)
break
;;
cancel)
exit
;;
*) if in_array picks $pick; then
picks=($(printf -- '%s\n' "${picks[@]}" | grep -v $pick));
else
picks+=("$pick")
fi
printf 'Selected: %s\n' "${picks[*]}"
;;
esac
done
if [[ $picks ]]; then
printf 'Removing %s\n' "${picks[*]}"
sudo mhwd-kernel -r "${picks[@]}"
fi
}
mhwd-kernel -li | awk 'NR==1 {print $4}' | tr -d '()' > .running_kernel &
mhwd-kernel -li | awk 'NR > 2 { print $2}' > .installed_kernels &
mhwd-kernel -l | awk 'NR > 1 { print $2}' > .available_kernels &
inxi -c 5 -b > .inxi_info &
while true; do
clear
echo ""
echo -e " $NC ::Hardware:: "
echo -e " ┌────────────────────────────────────────────────────────────────────────────┐"
echo -e " │ 1 Install a kernel 2 Remove a kernel │"
echo -e " │ 3 Use free graphics 4 Use nonfree graphics │"
echo -e " │ 5 List installed drivers 6 Configure touchpad │"
echo -e " │ 7 Configure printers 8 Configure monitors │"
echo -e " └────────────────────────────────────────────────────────────────────────────┘"
echo -e " $NC ::Information:: "
echo -e " ┌────────────────────────────────────────────────────────────────────────────┐"
echo -e " │ I Basic system information T System temperatures │"
echo -e " │ D Disk usage U Home folder usage │"
echo -e " │ H Detailed hardware information B Bios information │"
echo -e " │ P Processor information M Mountpoints and partitions│"
echo -e " └────────────────────────────────────────────────────────────────────────────┘"
echo -e " Select a number 0 Exit mhwd-tui"
echo ""
read -s -n1 choix
case $choix in
1)
echo
install_kernel
echo ""
;;
2)
echo
remove_kernel
echo ""
;;
3)
echo
sudo mhwd -a pci free 0300
echo ""
echo "Done. Press any key to continue"
read
echo ""
;;
4)
echo
sudo mhwd -a pci nonfree 0300
echo ""
echo "Done. Press any key to continue"
read
echo ""
;;
5)
echo
mhwd -li -d
echo ""
echo "Press any key to continue"
read
echo ""
;;
6)
echo
xinput_tui
echo ""
echo "Press any key to continue"
read
echo ""
;;
7)
echo
bcups
echo ""
echo "Press any key to continue"
read
echo ""
;;
8)
echo
brandr
echo ""
echo "Press any key to continue"
read
echo ""
;;
I|i)
echo
inxi -c 5 -b
echo ""
echo "Press any key to continue"
read
echo ""
;;
T|t)
echo
sensors
echo ""
echo "Press any key to continue"
read
echo ""
;;
D|d)
echo
ncdu -x /
echo ""
echo "Press any key to continue"
read
echo ""
;;
B|b)
echo
sudo dmidecode -t bios
echo ""
echo "Press any key to continue"
read
echo ""
;;
P|p)
echo
sudo dmidecode -t processor
lscpu
echo ""
echo "Press any key to continue"
read
echo ""
;;
H|h)
echo
sudo lshw > .lshw && nano .lshw
rm .lshw
echo ""
echo "Press any key to continue"
read
echo ""
;;
U|u)
echo
ncdu -x $HOME
echo ""
echo "Press any key to continue"
read
echo ""
;;
M|m)
echo
lsblk -o NAME,SIZE,FSTYPE,LABEL,MOUNTPOINT,UUID
echo ""
echo "Press any key to continue"
read
echo ""
;;
0)
clear && exit
read
;;
*)
echo -e "$RED Wrong option $NC"
echo "Wait and try again later..."
echo ""
sleep 3
clear
;;
esac
done
fi