-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrofi-auracle
executable file
·183 lines (160 loc) · 3.92 KB
/
rofi-auracle
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
#!/usr/bin/env bash
# config
downloaddir=$HOME/Downloads/builds
rofioption="-lines 10 -yoffset -20 -width 80"
terminal=$(which termite)
editor="$(which nvim-qt) --nofork -- -u $HOME/.config/slim-vim/init.vim"
_rofi() {
rofi ${rofioption} -dmenu -i -p "rofi-auracle" "$@"
}
buildpkg() {
IFS=$'\n'
buildsarr=($(ls $downloaddir | sed 's/:.*//'))
unset IFS
buildlist=""
for build in "${buildsarr[@]}"
do
if [ -z "$buildlist" ]; then
buildlist="${build}"
else
buildlist="$buildlist|${build}"
fi
done
build=$(echo $buildlist | _rofi -sep "|")
resp=$?
if [ $resp = 0 ]; then
if ( $(hasAURDeps $build) ); then
cd $downloaddir
confirm=$(echo "Yes|No" \
| _rofi -sep "|" -mesg \
"$build has deps from the AUR.
$(getAURDeps $build)
Go through building deps?")
if [ "$confirm" = "Yes" ]; then
for dep in $(getAURDeps $build); do
${editor} $dep/PKGBUILD
done
confirm=$(echo "Yes|No" | _rofi -sep "|" -mesg "Build all deps for $build?")
if [ "$confirm" = "Yes" ]; then
for d in $(getAURDeps $build); do
building $d
done
fi
fi
fi
cd $downloaddir/$build
${editor} PKGBUILD
confirm=$(echo "Yes|No" | _rofi -sep "|" -mesg "Build $build?")
if [ "$confirm" = "Yes" ]; then
building $build
fi
fi
}
building() {
${terminal} -d $downloaddir/$1 \
-e "makepkg -si" --hold && \
notify-send "rofi-auracle" "Build complete for $1"
}
hasAURDeps() {
package=$1
aurdeps=$(getAURDeps $package)
if [ -n "$aurdeps" ]; then
return 0
fi
return 1
}
getAURDeps() {
package=$1
aurdeps=$(auracle buildorder $package | grep -E '^(SATISFIED)?AUR' | cut -d ' ' -f2)
echo "${aurdeps[@]}"
}
clean() {
IFS=$'\n'
buildsarr=($(ls $downloaddir | sed 's/:.*//'))
unset IFS
buildlist="all"
for build in "${buildsarr[@]}"
do
buildlist="$buildlist|${build}"
done
build=$(echo $buildlist | _rofi -multi-select -sep "|")
val=$?
if [ "$val" != "1" ]; then
confirm=$(echo "No|Yes" | _rofi -sep "|" -mesg "Removing ($build). Are you sure?")
if [ "$confirm" = "No" ]; then
exit 0
fi
if [ "$build" = "all" ]; then
rm -drf $downloaddir/* && notify-send "rofi-auracle" "Cleaned."
else
for dir in ${build[@]}; do
rm -drf $downloaddir/$dir
done && notify-send "rofi-auracle" "Deleted\n${build[@]}"
fi
fi
}
download() {
if [ "$1" != "" ]; then
pkgs=$(echo "$@" | tr ' ' '\n')
auracle download -r -C $downloaddir "$@" && \
notify-send "rofi-auracle" "Downloaded:\n$pkgs"
fi
}
search() {
query=$(_rofi)
if [ "$query" = "" ]; then
exit 0
fi
selection=$(auracle search --sort=popularity "$query" -F $'{name}: {description}' | _rofi)
if [ "$selection" != "" ]; then
package=$(echo "$selection" | cut -d : -f1)
description=$(echo "$selection" | cut -d : -f2)
if [ "$1" = "download" ]; then
infomsg=" Package : $package
Description :$description
Download?"
confirm=$(echo "Yes|No" | _rofi -sep '|' -mesg "$infomsg")
if [ "$confirm" = "Yes" ]; then
download $package
fi
elif [ "$1" = "info" ]; then
auracle info "$package" | _rofi
fi
fi
}
sync() {
upgradehelp="<b>Shift+Enter</b> to multi-select"
choices=($(auracle sync -q | _rofi -multi-select -mesg "$upgradehelp"))
if [ "$choices" != "" ]; then
download "${choices[@]}"
fi
}
main() {
if [ ! -d "$downloaddir" ]; then
echo "Please set \$downloaddir"
exit 1
fi
mainmenu="search|sync|build|clean|info|goto build dir"
entrance=$(echo $mainmenu | _rofi -sep '|')
case $entrance in
"search")
search download
;;
"sync")
sync
;;
"build")
buildpkg
;;
"clean")
clean
;;
"info")
search info
;;
"goto build dir")
${terminal} -d $downloaddir
;;
esac
}
main