#!/bin/bash
-verstr="XbpsUI 2.0.1"
+verstr="XbpsUI 2.0.2"
# Evaluate command line:
for arg in "$@" ; do
echo "$verstr"
exit 0
;;
- "-d")
- use_dialog=1
- ;;
"-h"|*)
- echo "Usage: $(basename $0) [-d] [-h] [-V]"
- echo " -d use dialog(1) to display the main menu, not fzf(1)"
+ echo "Usage: $(basename $0) [-h] [-V]"
echo " -h display this help page"
echo " -V display version info and exit"
exit 0
# Check/install essential prerequisites:
pinst=""
preq="fzf gawk"
-[[ "$use_dialog" == "1" ]] && preq="dialog $preq"
for cmd in $preq ; do
if ! command -pv "$cmd" > /dev/null ; then
pinst="$pinst $cmd"
trapWithArg cleanup EXIT SIGINT SIGTERM SIGQUIT SIGHUP
-
-# Create resource file for dialog:
-if [[ "$use_dialog" == "1" ]] ; then
-echo "# dialogrc
-use_colors = ON
-use_shadow = OFF
-screen_color = (WHITE,BLACK,ON)
-shadow_color = (BLACK,BLACK,OFF)
-dialog_color = (WHITE,BLACK,OFF)
-title_color = (WHITE,BLACK,ON)
-border_color = (BLACK,BLACK,ON)
-button_active_color = (BLACK,WHITE,ON)
-button_inactive_color = dialog_color
-button_key_active_color = button_active_color
-button_key_inactive_color = (RED,BLACK,ON)
-button_label_active_color = (BLACK,WHITE,ON)
-button_label_inactive_color = (WHITE,BLACK,ON)
-menubox_color = screen_color
-menubox_border_color = border_color
-item_color = dialog_color
-item_selected_color = (BLACK,WHITE,OFF)
-tag_color = title_color
-tag_selected_color = button_label_active_color
-tag_key_color = button_key_inactive_color
-tag_key_selected_color = (RED,WHITE,ON)
-border2_color = dialog_color
-menubox_border2_color = dialog_color
-" > $tmp/dialogrc
-fi
-
# Pretty printing:
function prmsg() {
case "$1" in
# Main menu:
function menu() {
- if [[ -n $use_dialog ]] ; then
- # Use dialog(1) for main menu.
- # NOTE: Using explicit output redirection, as dialog's --stdout
- # option allegedly might fail in unexpected ways. Go figure.
- exec 3>&1
- choice=$( \
- DIALOGRC=$tmp/dialogrc \
- dialog \
- --title "$verstr" \
- --begin 1 0 \
- --cancel-label 'Quit' \
- --colors \
- --no-lines \
- --no-shadow \
- --menu '' 19 60 15 \
- 'sync' 'Synchronize repository package database' \
- 'upgrade' 'Update all packages to their latest version' \
- 'install' 'Install a new package' \
- 'reinstall' 'Re-install an already installed package' \
- 'purge' 'Remove a currently installed package' \
- 'reconfig' 'Forcibly reconfigure an installed package' \
- 'clean' 'Remove obsolete packages from cache' \
- 'orphan' 'Remove orphaned packages' \
- 'manual' 'Mark packages as manually installed' \
- 'auto' 'Mark packages as automatically installed' \
- 'hold' 'Set packages on hold' \
- 'unhold' 'Unhold held packages' \
- 2>&1 1>&3 \
- )
- res=$?
- exec 3>&-
- clear
- if (( $res != 0 )) ; then
- # quit / cancel menu
- exit 0
- fi
- else
- # Use fzf(1) for main menu.
- choice="$( echo "\
+ choice="$( echo "\
sync Synchronize repository package database
upgrade Update all packages to their latest version
install Install a new package
hold Set packages on hold
unhold Unhold held packages
quit Quit" |
- fzf -i \
- --no-multi \
- --exact \
- --bind q:abort,home:top,end:page-down \
- --no-sort \
- --cycle \
- --reverse \
- --margin="4%,1%,1%,2%" \
- --inline-info \
- --header=$'\n'"$verstr"$'\n\n' |
- awk '{ print $1 }'
- )"
- if [[ -z "$choice" ]] ; then
- # quit / cancel menu
- exit 0
- fi
+ fzf -i \
+ --no-multi \
+ --exact \
+ --bind q:abort,home:top,end:page-down \
+ --no-sort \
+ --cycle \
+ --reverse \
+ --margin="4%,1%,1%,2%" \
+ --inline-info \
+ --header=$'\n'"$verstr"$'\n\n' |
+ awk '{ print $1 }'
+ )"
+ if [[ -z "$choice" ]] ; then
+ # quit / cancel menu
+ exit 0
fi
# Perform requested action:
"hold" ) holdPkg ;;
"unhold" ) unholdPkg ;;
"quit" ) exit 0 ;;
- * ) echo "Action not implemented, WTF!?!" ; false ;;
+ * ) echo "$choice: Action not implemented, WTF!?!" ; false ;;
esac
return $?
}