Add Dialogs And Menus To Shell Scripts With Whiptail

  Рет қаралды 19,485

DistroTube

DistroTube

Жыл бұрын

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.org/wiki/Bash_Sh...
► askubuntu.com/questions/77683...
► gitlab.com/dtos/dtos/-/blob/m...
WANT TO SUPPORT THE CHANNEL?
💰 Patreon: / distrotube
💳 Paypal: kzbin.info?even...
🛍️ Amazon: amzn.to/2RotFFi
👕 Teespring: teespring.com/stores/distrotube
DONATE CRYPTO:
💰 Bitcoin: 1Mp6ebz5bNcjNFW7XWHVht36SkiLoxPKoX
🐶 Dogecoin: D5fpRD1JRoBFPDXSBocRTp8W9uKzfwLFAu
📕 LBC: bMfA2c3zmcLxPCpyPcrykLvMhZ7A5mQuhJ
DT ON THE WEB:
🕸️ Website: distrotube.com/
📁 GitLab: gitlab.com/dwt1
🗨️ Mastodon: fosstodon.org/@distrotube
👫 Reddit: / distrotube
📽️ LBRY/Odysee: odysee.com/@DistroTube:2
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/tenacityteam/tenacity
💻 VirtualBox: www.virtualbox.org/
🗒️ Doom Emacs: github.com/hlissner/doom-emacs
Your support is very much appreciated. Thanks, guys!

Пікірлер: 33
@muddyexport5639
@muddyexport5639 Жыл бұрын
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 ;~) .
@driden1987
@driden1987 Жыл бұрын
Wow thought this was going to be about gum, thanks for sharing DT
@sumirandahal76
@sumirandahal76 Жыл бұрын
Just wanted to watch DT's videos, and got this in the feed. Thank you sir !!
@minma02262
@minma02262 2 ай бұрын
I learned newt in university 10 plus years ago. I like it.
@user-hc6uo5fp8n
@user-hc6uo5fp8n Жыл бұрын
Thank you I know what I will be play with for the next week or so keep up the good work.
@bigmikeobama5314
@bigmikeobama5314 Жыл бұрын
Please keep up the great work dt!
@miko007
@miko007 Жыл бұрын
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.
@RAndrewNeal
@RAndrewNeal Жыл бұрын
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 Жыл бұрын
Awesome content!
@anon_y_mousse
@anon_y_mousse Жыл бұрын
It's like the universe is pushing me to make my own distro, or at the very least to do LFS.
@navarrodba
@navarrodba 11 ай бұрын
oh.. this is really cool!!!
@5HT2A292
@5HT2A292 Жыл бұрын
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 ...
@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
@007arek
@007arek Жыл бұрын
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 Жыл бұрын
Can you interact with these TUI dialogs with the mouse?
@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)
@quarteratom
@quarteratom Жыл бұрын
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.
@squalazzo
@squalazzo Жыл бұрын
if i remember correctly, you can put 0 0 0 as numbers and get autosize
@jackelofnar
@jackelofnar Жыл бұрын
Isn't gum a better option for this than Whiptail?
@masterdoyen
@masterdoyen Жыл бұрын
You should make it so if the package is installed already, grey out the package and put (installed) after the name of the package
@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
@lonehayena
@lonehayena Жыл бұрын
When are you going to review SerenityOS?
@noferblatz
@noferblatz Жыл бұрын
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 Жыл бұрын
This script needs to be able to run in a tty. After all, it is mainly an Arch Linux post-installation script.
@HelmutFischer-thehefi
@HelmutFischer-thehefi Жыл бұрын
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.
@-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. 🙏👍
@helgi2925
@helgi2925 Жыл бұрын
No Midori browser in the list? So bad :D
@stes1647
@stes1647 Жыл бұрын
Whiptill?
@anonytuser711
@anonytuser711 Жыл бұрын
Hey @DistroTube - @eBuzzCentral Troy reviewed a 2 year old release of InstantOS beta here: kzbin.info/www/bejne/n2SliqmfhqiEnZo 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.
Let's Share Our Favorite Bash Aliases
16:28
DistroTube
Рет қаралды 30 М.
Пранк пошел не по плану…🥲
00:59
Саша Квашеная
Рет қаралды 6 МЛН
Каха заблудился в горах
00:57
К-Media
Рет қаралды 9 МЛН
Inside Out Babies (Inside Out Animation)
00:21
FASH
Рет қаралды 18 МЛН
Xargs Should Be In Your Command Line Toolbag
16:24
DistroTube
Рет қаралды 97 М.
Creating GUIs in bash using the dialog command.
24:04
MyGeekAdventures
Рет қаралды 1,5 М.
Transform Your Scripts With Bash Simple Curses
16:15
DistroTube
Рет қаралды 107 М.
Add a Simple LOADING BAR To Your Shell Scripts!
16:26
CheesedUp
Рет қаралды 3,4 М.
Essential Keybindings For Bash, Fish and Zsh
16:41
DistroTube
Рет қаралды 28 М.
The Windows Source Code Revealed: Task Manager (E01)
27:11
Dave's Garage
Рет қаралды 447 М.
Write beautiful shell scripts with Gum! [Terminal Velocity 4]
13:23
Andrew Burgess
Рет қаралды 21 М.
Linux Mint vs... Linux Mint (Debian Edition)
17:43
Veronica Explains
Рет қаралды 256 М.
How To Use The Shell Commands 'pushd', 'popd' and 'dirs'
13:45
DistroTube
Рет қаралды 16 М.
Better Than Smart Phones☠️🤯 | #trollface
0:11
Not Sanu Moments
Рет қаралды 15 МЛН
iPhone 16 с инновационным аккумулятором
0:45
ÉЖИ АКСЁНОВ
Рет қаралды 10 МЛН
#samsung #retrophone #nostalgia #x100
0:14
mobijunk
Рет қаралды 13 МЛН
Это Xiaomi Su7 Max 🤯 #xiaomi #su7max
1:01
Tynalieff Shorts
Рет қаралды 2,1 МЛН
Запрещенный Гаджет для Авто с aliexpress 2
0:50
Тимур Сидельников
Рет қаралды 925 М.