From 4b839c0104760f3e98f05bb3ff392c812b87bd61 Mon Sep 17 00:00:00 2001 From: davidpaulos Date: Wed, 11 Apr 2018 17:04:29 +0100 Subject: [PATCH] first commit --- XbpsUI.sh | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 XbpsUI.sh diff --git a/XbpsUI.sh b/XbpsUI.sh new file mode 100644 index 0000000..10b95fe --- /dev/null +++ b/XbpsUI.sh @@ -0,0 +1,143 @@ +#!/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 "" | grep -v "*" | sort -k1,1 -u | + fzf -i \ + --multi \ + --exact \ + --no-sort \ + --select-1 \ + --query="$argument_input" \ + --cycle \ + --reverse \ + --margin="4%,1%,1%,2%" \ + --inline-info \ + --preview 'xbps-query -R {1} '\ + --preview-window=right:55%:wrap \ + --header="TAB key to (un)select. ENTER to install. ESC to quit." \ + --prompt="filter> " | + awk '{print $1}' + )" + + 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 -k1,1 -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 {1} '\ + --preview-window=right:55%:wrap \ + --header="TAB key to (un)select. ENTER to purge. ESC to quit." \ + --prompt="filter> " | + awk '{print $1}' + )" + + pkg="$( echo "$pkg" | paste -sd " " )" + if [[ -n "$pkg" ]] + then + clear + sudo xbps-remove -R $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 package │" + 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 debianUI 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 debianUI press ENTER \e[0m" + read + ;; + 3|i|install|install-packages ) + install + echo + echo -e " \e[41m Package installation finished. To return to debianUI press ENTER \e[0m" + read + ;; + 4|r|remove|remove-packages-and-deps ) + purge + echo + echo -e " \e[41m Package(s) purged. To return to debianUI 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 -- 2.30.2