forked from zen0bit/XbpsUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXbpsUI.sh
executable file
·205 lines (189 loc) · 6.62 KB
/
XbpsUI.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
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
#!/bin/bash
function update
{
#command to update de system
sudo xbps-install -Suv
}
function install
{
#declaration of local variables
local pkg
local argument_input
#selecting of packages to install
#flags multi to be able to pick multiple packages
#exact to match exact match
#no sort self explanatory
#cycle to enable cycle scroll
#reverse to set orientation to reverse
#margin for margins
#inline info to display info inline
#preview to show the package description
#header and prompt to give info for people to know how to do stuff
pkg="$( xbps-query -Rs "" | sort -u | grep -v "*" | fzf -i \
--multi --exact --no-sort --select-1 --query="$argument_input" \
--cycle --reverse --margin="4%,1%,1%,2%" \
--inline-info \
--preview 'xbps-query -R {2} '\
--preview-window=right:55%:wrap \
--header="TAB key to (un)select. ENTER to install. ESC to quit." \
--prompt="filter> " | awk '{print $2}'
)"
pkg="$( echo "$pkg" | paste -sd " " )"
if [[ -n "$pkg" ]]
then
clear
sudo xbps-install -S $pkg
fi
}
function purge
{
local pkg
local argument_input
pkg="$( xbps-query -l | sort -u |
fzf -i \
--multi \
--exact \
--no-sort \
--select-1 \
--query="$argument_input" \
--cycle \
--reverse \
--margin="4%,1%,1%,2%" \
--inline-info \
--preview 'xbps-query -S {2} '\
--preview-window=right:55%:wrap \
--header="TAB key to (un)select. ENTER to purge. ESC to quit." \
--prompt="filter> " |
awk '{print $2}'
)"
pkg="$( echo "$pkg" | paste -sd " " )"
if [[ -n "$pkg" ]]
then
clear
sudo xbps-remove -R $pkg
fi
}
function unhold
{
local pkg
local argument_input
pkg="$( xbps-query -p hold -s "" | sort -u |
fzf -i \
--multi \
--exact \
--no-sort \
--select-1 \
--query="$argument_input" \
--cycle \
--reverse \
--margin="4%,1%,1%,2%" \
--inline-info \
--header="TAB key to (un)select. ENTER to unhold. ESC to quit." \
--prompt="filter> " |
awk '{print $1}'
)"
pkg="$( echo "$pkg" | paste -sd " "| tr -d ":" )"
if [[ -n "$pkg" ]]
then
clear
sudo xbps-pkgdb -m unhold $pkg
fi
}
function hold
{
local pkg
local argument_input
pkg="$( xbps-query -l | sort -u |
fzf -i \
--multi \
--exact \
--no-sort \
--select-1 \
--query="$argument_input" \
--cycle \
--reverse \
--margin="4%,1%,1%,2%" \
--inline-info \
--preview 'xbps-query -S {2} '\
--preview-window=right:55%:wrap \
--header="TAB key to (un)select. ENTER to place on hold. ESC to quit." \
--prompt="filter> " |
awk '{print $2}'
)"
pkg="$( echo "$pkg" | paste -sd " " )"
if [[ -n "$pkg" ]]
then
clear
sudo xbps-pkgdb -m hold $pkg
fi
}
function maintain
{
sudo xbps-remove -Oo
}
function ui
{
while true
do
clear
echo
echo -e " \e[7m XbpsUI - Package manager \e[0m "
echo -e " ┌───────────────────────────────────────────────────────────────┐"
echo -e " │ 1 \e[1mU\e[0mpdate System 2 \e[1mM\e[0maintain System │"
echo -e " │ 3 \e[1mI\e[0mnstall Packages 4 \e[1mP\e[0murge packages │"
echo -e " │ 5 \e[1mH\e[0mold Packages 6 \e[1mU\e[0mnhold packages │"
echo -e " └───────────────────────────────────────────────────────────────┘"
echo -e " Enter number or marked letter(s) - 0 \e[1mQ\e[0muit "
read -r choice
choice="$(echo "$choice" | tr '[:upper:]' '[:lower:]' )"
echo
case "$choice" in
1|u|update|update-system )
update
echo
echo -e " \e[41m System updated. To return to xbpsUI press ENTER \e[0m"
# wait for input, e.g. by pressing ENTER:
read
;;
2|m|maintain|maintain-system )
maintain
echo
echo -e " \e[41m System maintenance finished. To return to xbpsUI press ENTER \e[0m"
read
;;
3|i|install|install-packages )
install
echo
echo -e " \e[41m Package installation finished. To return to xbpsUI press ENTER \e[0m"
read
;;
4|p|purge|purge-packages )
purge
echo
echo -e " \e[41m Package(s) purged. To return to xbpsUI press ENTER \e[0m"
read
;;
5|h|hold|hold-packages )
hold
echo
echo -e " \e[41m Package(s) held. To return to xbpsUI press ENTER \e[0m"
read
;;
6|u|unhold|unhold-packages )
unhold
echo
echo -e " \e[41m Package(s) unheld. To return to xbpsUI press ENTER \e[0m"
read
;;
0|q|quit|$'\e'|$'\e'$'\e' )
clear && exit
;;
* )
echo -e " \e[41m Wrong option \e[0m"
echo -e " Please try again... "
sleep 2
;;
esac
done
}
ui