-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrelease-aur-from-rss
executable file
·50 lines (41 loc) · 1.16 KB
/
release-aur-from-rss
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
#! /bin/sh
if [ "$1" = "--help" ] || [ "$1" = "-h" ] || [ "$1" = "help" ] || [ -z "$1" ]; then
cat <<EOF
$ release-aur-from-rss
Semiautomate the release of aur pkg via rss feeds
Called from a keybinding within newsboat (see config)
EOF
exit
fi
command -v tmux >/dev/null || { echo "tmux is not installed" 1>&2; exit 127; }
send_error() {
MSG="$1"
~/scripts/cron/cron-notify-send -u critical -t 5000 "$MSG" "newsboat-release"
exit 1
}
URL="$1"
PKG=$(echo $URL | cut -d/ -f5)
VERSION=$(echo $URL | cut -d/ -f8 | cut -dv -f2)
transform_pkgname() {
case "$PKG" in
webpack) echo nodejs-webpack;;
yacreader) echo yacreader-bin;;
phpactor) echo phpactor;;
portal) echo portal-bin;;
dzr) echo dzr;;
ain) echo ain-bin;;
# <++>) echo <++>;;
*) send_error "Matched non existant pkg: $PKG";;
esac
}
if [ -z "$PKG" ] || [ -z "$VERSION" ]; then
send_error "Invalid url given"
else
PKG_DIR="$HOME/code/aur/$(transform_pkgname)"
if [ ! -d "$PKG_DIR" ]; then
send_error "PKG_DIR does not exist locally for $PKG_DIR"
else
tmux -u new-window -t main -c "$PKG_DIR" -n "aur $PKG"
tmux send-keys "./release $VERSION" "enter"
fi
fi