nyxnor / onionjuggler

Manage your Onion Services via CLI or TUI on Unix-like operating system with a POSIX compliant shell.
MIT License
34 stars 2 forks source link

[ENHANCEMENT] Support whiptail as well as dialog for dialog boxes #6

Closed nyxnor closed 2 years ago

nyxnor commented 2 years ago

My doubt is / How can I:

@radio24 Have you encountered any problems/incompatibilities translating from whiptail to dialog? If no, I can make the menu also become a whiptail, else, might have to study to make them compatible in the code.

radio24 commented 2 years ago

I had the impression that the command lines for whiptail and dialog are (almost?) the same. For example:

dialog --clear --backtitle "${BACKTITLE}" --title "${TITLE}" --"${DIALOG_TYPE}" "${MENU}" "$((i+8))" 80 ${i} ${SERVICE_LIST} 2>&1 >/dev/tty)"

whiptail --clear --backtitle "${BACKTITLE}" --title "${TITLE}" --"${DIALOG_TYPE}" --separate-output "${MENU}" "$((i+8))" 80 $i ${SERVICE_LIST} 3>&1 1>&2 2>&3"

Both programs know the --separate-output option. However, I had the impression that with dialog, it worked without; with whiptail it is mandatory to use it, but I'm not sure about it. Also a difference is the 2>&1 >/dev/tty vs. the 3>&1 1>&2 2>&3 - I don't know if that matters.

nyxnor commented 2 years ago
nyxnor commented 2 years ago

Redirection was fixed on https://github.com/nyxnor/onionservice/commit/8b040f53866cb4013eb5492cd3b79e622f32eb72 When you test whiptail (no rush), let me know if it makes a difference using --separate-output or not.

radio24 commented 2 years ago

Ok ... here are the results: Result with --separate-output:

1
2
x

Result without --separate-output: "1" "2" "x"

I need --separate-output with the "for in do" loop. Of course, you can manipulate the result without --separate-output in so you can use it with the "for in do" loop.

nyxnor commented 2 years ago

This means that if I put --separate-output on dialog for the checklist, it becomes compatible with whiptail?

radio24 commented 2 years ago

dialog with --separate-output gives the same result as whiptail. dialog without --separate-output gives as result: 1 2 x

nyxnor commented 2 years ago

Ok, start supporting different dialog boxes -> whiptail and dialog. It is working with dialog but not with whiptail, I don't know why.

nyxnor commented 2 years ago

CHOICE_MAIN=--ok-label: unknown option

Dialog man Whiptail man

Dialog: --ok-label Whiptail: --ok-button

Why, just why...

Edit:

case "${DIALOG_BOX}" in
  dialog)
    OK_FLAG="--ok-label"
    NO_CANCEL_FLAG="--no-cancel"
  ;;
  whiptail)
    OK_FLAG="--ok-button"
    NO_CANCEL_FLAG="--nocancel"
  ;;
esac

Now I see what you mean by whiptail displaying the height option strangely. image

radio24 commented 2 years ago

Argh... the same problem exists with --yes-button --no-button and --cancel-button

nyxnor commented 2 years ago

Now need to convert inside the files

case "${DIALOG_BOX}" in
  dialog)
    YES_FLAG="--yes-label"
    NO_FLAG="--no-label"
    OK_FLAG="--ok-label"
    CANCEL_FLAG="--cancel-label"
    NO_CANCEL_FLAG="--no-cancel"
  ;;
  whiptail)
    YES_FLAG="--yes-button"
    NO_FLAG="--no-button"
    OK_FLAG="--ok-button"
    CANCEL_FLAG="--cancel-button"
    NO_CANCEL_FLAG="--nocancel"
  ;;
esac

Edit: all things converted, but this is so wrong: image

Another problem is that whiptail put an extra line on the text, so need to find some way to bypass that. Use spacebar to select , see the difference. image image

nyxnor commented 2 years ago

Little wip to start accepting whiptail here https://github.com/nyxnor/onionservice/commit/8801b53e1967714e9c2f10394646ad9901c3946e Still, there is more to do to adjust every dialog box.

nyxnor commented 2 years ago

Best solution I found for the height it adding one when it is whiptail, but need to edit every dialog height basically to "$((current_height+WHIPTAIL_HEIGHT))" Progress so far of testing with whiptail and dialog on:

nyxnor commented 2 years ago

db1f257a8579b70110ab2843842ce3363527e9f4 dd63d518f1aef0349ab4cb10d062e8509c62481c 5462753e0daceb0b9e90f7d86ebe0c0fd1b095c9

Ok. As I reviewed all the menu options with caution, I have found and fixed all the bugs that I encountered with. I tested with whiptail and dialog all options and they seem to fit.

This will be kept open for some days in the event a big bug is found.

nyxnor commented 2 years ago

Oh, and maybe it is good if you could test if it fits on the tiny lcd screen because I edited some heights to be "$((i+8+WHIPTAIL_HEIGHT)). If I dont add the WHIPTAIL_HEIGHT, it is gonna be short by one line when using whiptail.

nyxnor commented 2 years ago

no bugs so far, closing this.