Add Dialogs And Menus To Shell Scripts With Whiptail

Поділитися
Вставка
  • Опубліковано 6 лют 2025
  • Whiptail is a program that allows shell scripts to display dialog boxes and menus to the user for informational purposes, or to get input from the user in a friendly way. It is a way to add a UI to a shell script. Whiptail is included by default on Debian and many other Linux distros.
    REFERENCED:
    ► en.wikibooks.o...
    ► askubuntu.com/...
    ► gitlab.com/dto...
    WANT TO SUPPORT THE CHANNEL?
    💰 Patreon: / distrotube
    💳 Paypal: www.youtube.co...
    🛍️ Amazon: amzn.to/2RotFFi
    👕 Teespring: teespring.com/...
    DONATE CRYPTO:
    💰 Bitcoin: 1Mp6ebz5bNcjNFW7XWHVht36SkiLoxPKoX
    🐶 Dogecoin: D5fpRD1JRoBFPDXSBocRTp8W9uKzfwLFAu
    📕 LBC: bMfA2c3zmcLxPCpyPcrykLvMhZ7A5mQuhJ
    DT ON THE WEB:
    🕸️ Website: distrotube.com/
    📁 GitLab: gitlab.com/dwt1
    🗨️ Mastodon: fosstodon.org/...
    👫 Reddit: / distrotube
    📽️ LBRY/Odysee: odysee.com/@Di...
    FREE AND OPEN SOURCE SOFTWARE THAT I USE:
    🌐 Brave Browser - brave.com/dis872
    📽️ Open Broadcaster Software: obsproject.com/
    🎬 Kdenlive: kdenlive.org
    🎨 GIMP: www.gimp.org/
    🎵 Tenacity: github.com/ten...
    💻 VirtualBox: www.virtualbox...
    🗒️ Doom Emacs: github.com/hli...
    Your support is very much appreciated. Thanks, guys!

КОМЕНТАРІ • 32

  • @driden1987
    @driden1987 Рік тому +4

    Wow thought this was going to be about gum, thanks for sharing DT

  • @kev2020-z9s
    @kev2020-z9s Рік тому +2

    Thank you I know what I will be play with for the next week or so keep up the good work.

  • @muddyexport5639
    @muddyexport5639 Рік тому +9

    Food For Thought:
    Your spaces variable could be developed for each menu function taking the known screen length of 78 - scroll bar length including the hidden display attributes, and calculate the longest key variable length for each menu function selection list. Then, the known screen length - longest key length = the spaces variable for that menu selection function. Doing the spaces variable for each individual menu item would insure a uniform menu box. And as the menu choices expand or contract the value of spaces will not have to be jockeyed manually.
    I always try to leave code with the goal to not to have to rework for the changing, evolving work environment. Bullet Proof == always the goal though not always achieved.
    Again, just a thought (that may never be read ;~) .

  • @sumirandahal76
    @sumirandahal76 Рік тому

    Just wanted to watch DT's videos, and got this in the feed. Thank you sir !!

  • @RAndrewNeal
    @RAndrewNeal Рік тому +1

    For every package installation page, you could get the length of the longest string to be displayed, and subtract that from the total width you want them to occupy, and pad that many spaces, instead of padding a constant number. It'll be much cleaner and more visually consistent that way.

  • @darthcabs
    @darthcabs Рік тому +2

    Awesome content!

  • @miko007
    @miko007 Рік тому +4

    its actually not really weird, that you have to switch stdout and stderr around, for dialog, you also have to do this.
    if you have user input, whiptail has no way to report it back, as it needs stdout to draw the actual dialog. it so chooses the stderr file descriptor to put the user input somewhere. the you go ahead and switch stdout and stderr after whiptail is done running, so you now have the user input in stdout and can further process it.

  • @minma02262
    @minma02262 8 місяців тому

    I learned newt in university 10 plus years ago. I like it.

  • @anon_y_mousse
    @anon_y_mousse Рік тому +4

    It's like the universe is pushing me to make my own distro, or at the very least to do LFS.

  • @Winnetou17
    @Winnetou17 Рік тому

    Hey DT! Why don't you use printf for ensuring the right amount of spaces ? That for is actually ridiculous!
    In both the terminal and in C, you have printf. In terminal you would use this as
    printf "%78s
    " "text guaranteed to ocupy 78 characters, left padded"
    With 78 being the minimum width, s denoting that it's a string (and the default padding is a space for strings, a zero for numbers). This way (usually the norm with numbers) the padding is added to the left of the variable outputted, (aka right aligned) and that is kind of useless in your example. For that you have to add a minus to the width specifier, like this:
    printf "%-78s
    " "text left aligned but still 78 characters wide"
    Check the GNU documentation (you can check C documentation of the function too, but there's minor subtle differences between the C function and the shell program)

  • @5HT2A292
    @5HT2A292 Рік тому +4

    Hey DT, can you please make a video where you just say "sauerbraten" for 10 mins?

    • @jyvben1520
      @jyvben1520 Рік тому

      you could make a youtube short, it repeats automatically, till you close it ...

  • @jackelofnar
    @jackelofnar Рік тому +1

    Isn't gum a better option for this than Whiptail?

  • @007arek
    @007arek Рік тому +2

    Maybe someone has a good recommendation for a library or binding for lua? I'd like to make such a script but I don't like bash. I've found IUP but IDK if it is a good solution.

  • @quarteratom
    @quarteratom Рік тому +1

    Can you interact with these TUI dialogs with the mouse?

  • @noferblatz
    @noferblatz Рік тому +2

    If you use zenity instead, you don't need to be in a terminal for this to work. It runs natively in X Window, but its API is much like dialog and the rest.

    • @DistroTube
      @DistroTube  Рік тому +4

      This script needs to be able to run in a tty. After all, it is mainly an Arch Linux post-installation script.

  • @linuxrant
    @linuxrant Рік тому

    Hmm, that's pretty cool... I was looking for something like this and couldn't find nothing that would be relatively easy to make. Then Brodie made a video about Smenu, but then I realized I could just simply learn to make a python script using curses or urwid module... then you show this whiptail...and I get choice paralysis :)
    I think I'm gonna check everything one by one and get my hands a little dirty :)

    • @tylerdean980
      @tylerdean980 Рік тому

      Even easier is bash simple curses, DT has a vid on that too

  • @squalazzo
    @squalazzo Рік тому

    if i remember correctly, you can put 0 0 0 as numbers and get autosize

  • @navarrodba
    @navarrodba Рік тому

    oh.. this is really cool!!!

  • @alittlebitofeverything-1e
    @alittlebitofeverything-1e Рік тому

    You should make it so if the package is installed already, grey out the package and put (installed) after the name of the package

  • @quarteratom
    @quarteratom Рік тому +2

    BTW don't check and install programs this way. If the program is in path, but not installed with the package manager you use, the package manager will install it again. Either skip installing the programs you already marked as installed, or query the package manager whether they are installed, instead of looking for the executable in PATH.

  • @HelmutFischer-thehefi
    @HelmutFischer-thehefi Рік тому +2

    I think "Cancel" should cancel, so a third choice "Next" or "Skip" would be better for continuing on the next selection. Just my 2 cents.

  • @lonehayena
    @lonehayena Рік тому

    When are you going to review SerenityOS?

  • @theodorealenas3171
    @theodorealenas3171 Рік тому

    That's nuts! I've made fuzzy finding scripts that use fzf in the terminal, or dmenu if there's no terminal there (GUI key bindings)
    Btw I haven't watched the video, let me unpause the video and watch

  • @helgi2925
    @helgi2925 Рік тому +1

    No Midori browser in the list? So bad :D

  • @-someone-.
    @-someone-. Рік тому

    I love your vids. Would you do a showcase on the new Kali purple? It’s built specifically for a “defensive” setup, rather than the traditional offensive. 🙏👍

  • @stes1647
    @stes1647 Рік тому

    Whiptill?

  • @anonytuser711
    @anonytuser711 Рік тому

    Hey @DistroTube - @eBuzzCentral Troy reviewed a 2 year old release of InstantOS beta here: ua-cam.com/video/i3BYviQCQg8/v-deo.html even though the new beta came out 2 weeks ago. He didn't use rofi and used a mouse instead of keybindings in his "review". I would love to hear your take on this.