diff options
Diffstat (limited to 'abraham-porter.sh')
-rwxr-xr-x | abraham-porter.sh | 112 |
1 files changed, 62 insertions, 50 deletions
diff --git a/abraham-porter.sh b/abraham-porter.sh index 1498ccf..ec4ca55 100755 --- a/abraham-porter.sh +++ b/abraham-porter.sh @@ -4,10 +4,10 @@ dmenu="rofi -dmenu" doas="doas" terminal="alacritty" -printer="rofi -width -81 -e" +pager="rofi -location 2 -width -81 -e" ports_dir="/usr/local/poudriere/ports/default" pkglist="$HOME/.pkglist" -poudriere_jail="121x64" +jail="121x64" ## Error codes @@ -16,33 +16,30 @@ NO_ACTION_PROVIDED=3 NO_PORT_PROVIDED=4 NO_PKG_DESCR_FOUND=5 NO_WANT_TERM_PROVIDED=6 +NO_WANT_ANOTHER_PROVIDED=7 ## Gets a port name from the user with dmenu get_port() { cwd=$(pwd) cd "$ports_dir" - printf "%s\n" */* | $dmenu -p "Choose a port" + printf "%s\n" */* | $dmenu -p "Port" cd "$cwd" } ## Prompt user if they want to run command in a new term wants_term() { - choice=$($dmenu -p "Do you want to do this in a new terminal?" << EOF -no -yes -EOF - ) - [ $action = "yes" ] && return 1 - [ $action = "no" ] && return 0 + choice=$(printf "no\nyes\n" | $dmenu -p "Do you want to do this in a new terminal?") + [ $choice = "no" ] && return 1 + [ $choice = "yes" ] && return 0 exit $NO_WANT_TERM_PROVIDED } ## Gets an action from the user with dmenu get_action() { - action=$($dmenu -p "Whadyagonnado" << EOF + action=$($dmenu -p "Abraham Porter" << EOF 1. print pkg-descr 2. set options 3. set options, add to pkglist @@ -64,7 +61,7 @@ handle_print_pkg_desc() { pkg_descr="$ports_dir"/$port/pkg-descr [ ! -f "$pkg_descr" ] && exit $NO_PKG_DESCR_FOUND text=$(cat "$ports_dir"/$port/pkg-descr) - $printer "$text" + $pager "$text" } @@ -114,42 +111,57 @@ handle_poudriere_bulk_pkglist() { } +get_another() { + choice=$($dmenu -p "Do you want another?" << EOF +no +yes +EOF + ) + [ $choice = "no" ] && return 1 + [ $choice = "yes" ] && return 0 + exit $NO_WANT_ANOTHER_PROVIDED +} + + ## Main -action=$(get_action) -case $action in - 1) - # 1. print pkg-descr - handle_print_pkg_desc - ;; - 2) - # 2. set options - handle_poudriere_options_single $(get_port) - ;; - 3) - # 3. set options, add to pkglist - handle_poudriere_options_single $(handle_append_pkglist $(get_port)) - ;; - 4) - # 4. set options, build pkg - handle_poudriere_bulk_single $(handle_poudriere_options_single $(get_port)) - ;; - 5) - # 5. set options, build pkg, add to pkglist - handle_poudriere_bulk_single $(handle_poudriere_options_single $(handle_append_pkglist $(get_port))) - ;; - 6) - # 6. add to pkglist - handle_append_pkglist $(get_port) - ;; - 7) - # 7. set options on pkglist - handle_poudriere_options_pkglist - ;; - 8) - # 8. build entire pkglist (lengthy and intensive!) - handle_poudriere_bulk_pkglist - ;; - *) - exit $NO_ACTION_PROVIDED - ;; -esac +while true; do + action=$(get_action) + case $action in + 1) + # 1. print pkg-descr + handle_print_pkg_desc + ;; + 2) + # 2. set options + handle_poudriere_options_single $(get_port) + ;; + 3) + # 3. set options, add to pkglist + handle_poudriere_options_single $(handle_append_pkglist $(get_port)) + ;; + 4) + # 4. set options, build pkg + handle_poudriere_bulk_single $(handle_poudriere_options_single $(get_port)) + ;; + 5) + # 5. set options, build pkg, add to pkglist + handle_poudriere_bulk_single $(handle_poudriere_options_single $(handle_append_pkglist $(get_port))) + ;; + 6) + # 6. add to pkglist + handle_append_pkglist $(get_port) + ;; + 7) + # 7. set options on pkglist + handle_poudriere_options_pkglist + ;; + 8) + # 8. build entire pkglist (lengthy and intensive!) + handle_poudriere_bulk_pkglist + ;; + *) + exit $NO_ACTION_PROVIDED + ;; + esac + get_another || exit OK +done |