improved messages

This commit is contained in:
zenobit 2023-03-29 20:16:55 +02:00
parent 22387b1355
commit a39cc83b6e
1 changed files with 51 additions and 19 deletions

70
dh
View File

@ -303,7 +303,7 @@ function run_tui() {
check_tui_dependencies check_tui_dependencies
cd "$VMS_DIR" || exit 1 cd "$VMS_DIR" || exit 1
vms=(*.conf) vms=(*.conf)
printf ' Prepared VMs:\n-------------\n\n' printf $" Prepared VMs:\n-------------\n\n"
# Check if there are any VMs # Check if there are any VMs
if [ ${#vms[@]} -eq 0 ]; then if [ ${#vms[@]} -eq 0 ]; then
echo $"No VMs found." echo $"No VMs found."
@ -313,65 +313,81 @@ function run_tui() {
printf "%s\n" "${vms[@]%.*}" printf "%s\n" "${vms[@]%.*}"
echo "-------------" echo "-------------"
# Action prompt # Action prompt
printf " Do you want to create a new VM? (c) echo $" Do you want to create a new VM? (c)"
or run an existing one? (press anything)\n" printf $" or run an existing one? (press anything)\n"
read -rn 1 -s start read -rn 1 -s start
case $start in case $start in
c ) c )
todo="create" todo="create"
;; ;;
esac esac
# If the user chose to create a new VM # If the user chose to create a new VM
if [ "$todo" = "create" ]; then if [ "$todo" = "create" ]; then
os=$("$prefix"quickget | sed 1d | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose OS to download os=$("$prefix"quickget | sed 1d | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose OS to download
or CTRL-c or ESC to quit') or CTRL-c or ESC to quit')
# If the OS is Windows # If the OS is Windows
if [ "$os" = windows ]; then if [ "$os" = windows ]; then
answer=$(echo "Default English answer=$(echo "Default English
Choose other language" | fzf --cycle) Choose other language" | fzf --cycle)
# If the user wants another windows language # If the user wants another windows language
if [ "$answer" = "Choose other language" ]; then if [ "$answer" = "Choose other language" ]; then
wrelease=$(echo "8 wrelease=$(echo "8
10 10
11" | fzf --cycle) 11" | fzf --cycle)
# get window language list # get window language list
wlend=$(($(cat "$prefix"quickget | sed '/Arabic/,$!d' | grep -n '}' | cut -d':' -f1 | head -n 1) - 1)) wlend=$(($(cat "$prefix"quickget | sed '/Arabic/,$!d' | grep -n '}' | cut -d':' -f1 | head -n 1) - 1))
# get windows language # get windows language
wlang=$(cat "$prefix"quickget | sed '/Arabic/,$!d' | head -n $wlend | cut -d'=' -f2 | tail -c +2 | head -c -2 | sed 's/^[ \t]*//' | fzf --cycle --header='Choose Language wlang=$(cat "$prefix"quickget | sed '/Arabic/,$!d' | head -n $wlend | cut -d'=' -f2 | tail -c +2 | head -c -2 | sed 's/^[ \t]*//' | fzf --cycle --header='Choose Language
or CTRL-c or ESC to quit') or CTRL-c or ESC to quit')
# downloading windows # downloading windows
printf '\n Trying to download Windows %s %s...\n\n' "$wrelease" "$wlang" printf $"\n Trying to download Windows %s %s...\n\n" "$wrelease" "$wlang"
"$prefix"quickget "windows" "$wrelease" "$wlang" "$prefix"quickget "windows" "$wrelease" "$wlang"
fi fi
fi fi
# Get the release and edition to download, if necessary # Get the release and edition to download, if necessary
choices=$("$prefix"quickget "$os" | sed 1d) choices=$("$prefix"quickget "$os" | sed 1d)
if [ "$(echo "$choices" | wc -l)" = 1 ]; then if [ "$(echo "$choices" | wc -l)" = 1 ]; then
# get release # get release
release=$(echo "$choices" | grep 'Releases' | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose Release release=$(echo "$choices" | grep 'Releases' | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose Release
or CTRL-c or ESC to quit') or CTRL-c or ESC to quit')
# downloading # downloading
printf '\n Trying to download %s %s...\n\n' "$os" "$release" printf $"\n Trying to download %s %s...\n\n" "$os" "$release"
"$prefix"quickget "$os" "$release" "$prefix"quickget "$os" "$release"
else else
# get release # get release
release=$(echo "$choices" | grep 'Releases' | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose Release release=$(echo "$choices" | grep 'Releases' | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose Release
or CTRL-c or ESC to quit') or CTRL-c or ESC to quit')
# get edition # get edition
edition=$(echo "$choices" | grep 'Editions' | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose Edition edition=$(echo "$choices" | grep 'Editions' | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose Edition
or CTRL-c or ESC to quit') or CTRL-c or ESC to quit')
# downloading # downloading
printf '\n Trying to download %s %s %s...\n\n' "$os" "$release" "$edition" printf $"\n Trying to download %s %s %s...\n\n" "$os" "$release" "$edition"
"$prefix"quickget "$os" "$release" "$edition" "$prefix"quickget "$os" "$release" "$edition"
fi fi
# choose VM to run # choose VM to run
choosed=$(echo "$(ls ./***.conf 2>/dev/null | sed 's/\.conf$//')" | fzf --cycle --header='Choose VM to run choosed=$(echo "$(ls ./***.conf 2>/dev/null | sed 's/\.conf$//')" | fzf --cycle --header='Choose VM to run
or CTRL-c or ESC to quit') or CTRL-c or ESC to quit')
# Run choosed VM # Run choosed VM
printf '\n Starting %s...\n\n' "$choosed" printf $"\n Starting %s...\n\n" "$choosed"
"$prefix"quickemu -vm "$choosed.conf" "$prefix"quickemu -vm "$choosed.conf"
fi fi
} }
# more # more
function isos_to_dir() { function isos_to_dir() {
yad --file --directory > target yad --file --directory > target
@ -390,25 +406,40 @@ function add_distro() {
URL="$(cat ${TMP_DIR}/template.tmp | cut -d'|' -f5)" URL="$(cat ${TMP_DIR}/template.tmp | cut -d'|' -f5)"
ISO="$(cat ${TMP_DIR}/template.tmp | cut -d'|' -f6)" ISO="$(cat ${TMP_DIR}/template.tmp | cut -d'|' -f6)"
CHECKSUM_FILE="$(cat ${TMP_DIR}/template.tmp | cut -d'|' -f7)" CHECKSUM_FILE="$(cat ${TMP_DIR}/template.tmp | cut -d'|' -f7)"
echo " $NAME) PRETTY_NAME=$PRETTY_NAME;;
" > "${TMP_DIR}/${NAME}".tmp cat <<EOF > "${TMP_DIR}"/template.tmp
{ echo " $NAME \\ #32
"; echo "function releases_$NAME() {
$NAME) PRETTY_NAME="$PRETTY_NAME";;
#184+
$NAME \\
#262+
function releases_$NAME() {
echo $RELEASES echo $RELEASES
} }
"; echo "function editions_$NAME() {
function editions_$NAME() {
echo $EDITIONS echo $EDITIONS
} }
"; echo "function get_$NAME() {
local EDITION="${1:-}" #1052+
function get_$NAME() {
local EDITION="\${1:-}"
local HASH="" local HASH=""
local ISO="$ISO" local ISO="$ISO"
local URL="$URL" local URL="$URL"
HASH=\"$(wget -q -O- "${URL}/${CHECKSUM_FILE}" | grep "(${ISO}" | cut -d' ' -f4)\" HASH="\$(wget -q -O- \${URL}/\${CHECKSUM_FILE} | grep (\${ISO} | cut -d' ' -f4)"
echo \"${URL}/${ISO} ${HASH}\" echo "\${URL}/\${ISO}" "\${HASH}"
} }
"; } >> "${TMP_DIR}/${NAME}".tmp
meld "${TMP_DIR}/${NAME}.tmp $DH_CONFIG_DIR/quickget" EOF
echo "Done"
meld "${TMP_DIR}"/template.tmp "$DH_CONFIG_DIR"/quickget
} }
function sort_functions() { function sort_functions() {
@ -428,7 +459,8 @@ function sort_functions() {
} }
function create_translation() { function create_translation() {
echo $"Which language use [en,cs]?" echo $"Which language change? [en,cs]"
echo $"If you want create new one, insert two digit language code..."
read -rn 2 -s lang read -rn 2 -s lang
echo $"Choosed language is: $lang" echo $"Choosed language is: $lang"
echo $"Dumping language source..." echo $"Dumping language source..."