Modernize your Bash Scripts by adding GUI
medium.com
medium.com
You have 1 free story left this month. Sign up and get an extra one for free.
I really dislike Medium. I don't want to have a relationship with the blog platform that people use in order to read the article; I want to read the article.I use firefox with NoScript and Privacy Badger, and I disallow cookies. Hopefully this helps.
Frankly, I would really prefer to just pay for articles I liked (as opposed to a subscription), but this option is not available :(
I usually selectively enable JS. If I care enough about the content that's disabled then I'll enable it from some sources for some sites.
> Frankly, I would really prefer to just pay for articles I liked (as opposed to a subscription), but this option is not available :(
This would also be preferable.
If you want to see "user unfriendliness", just present your user with the cryptic error message they'll receive in either of those instances (ask 'em how "modern" they think your script is then)!
I'm obviously not the "target market" for this article anyways but a better example might have included, at the minimum, some basic error checking or perhaps even a graceful fallback to dialog or whiptail or similar.
However I'm not _always_ a terminal user. Sometimes I'm a browser user and sometimes I have to use spreadsheets too.
In these contexts I use other programs which have GUI's, sometimes quite minimal, like a screenshot app for example.
I can certainly imagine getting a spreadsheet into a defined set of columns and then executing another app which asks a set of questions and then does something with that data, maybe even only draws a graph (as I despize drawing graphs in spreadsheets).
In this context, I feel that I may well write BASH, but opening a terminal would be as jarring as leaving it under normal circumstances...
So I feel these kind of tools are useful.
Shameless plug: Funnily I'm working on the opposite. Integrating STDIN/STDOUT into the GUI via a WebView, because I want that command line control but I there are occasions where there are benefits in using a GUI (graphs etc) - https://github.com/forbesmyester/wv-linewise
For example, I have a script bound to Super+Y that opens a youtube video inside a local video player. Before it starts the video it shows a zenity popup with the URL so I can confirm that it is correct.
My pitch for zenity would be - "Need a prototype gui for users that struggle in the console? Consider zenity."
Old ideas are often the best ones, why shove everything down the drain every five years?
There was xdialog 20 years ago. And libnotify has like 15 years too.
I understand "modern bash" as in any other scripting or programming language: It's about what caveats of the language quirks, the optimizations and the failure scenarios, that you solve with your code conventions, which people didn't use to use, some years ago.
Change things for the sake of having something "newer" available for me, is something I try to avoid at all levels of my life.
alias n="notify-send Completed."notify-send won't work for dudik since, as he said, he doesn't use a notification server.
echo -e "command\n with a long output,\n and it's last line" |tee /dev/tty| tail -n 1| { read -d '\n' _output ; notify-send "$_output"; telegram-send "$_output"; }
This will send the last n lines of stdout to:- gnome-notifications
- telegram on my phone from a bot account that uses a unique notification sound
Did you wind up picking something else?
"long build has completed"
is pretty much my primary notification.
Like:
dialog --title "Message" --yesno "Continue?" 6 25
echo $? # will be 0 for yes, 1 for noIf you think it was to avoid using a gui, I would have to say that's not really it.
It's more to do something (automate stuff) rather than not do something.
I learned about zenity but chose yad instead - it has the same interface + a few more bells and whistles.
What it's good for is launching something you'll do on your primary display, that has a lot of options that you might change individually.
probably also good for a phone. I learned about yad reading this article:
https://wp.puri.sm/posts/easy-librem-5-app-development-flash...
This blog post is basically about using GUI inputs to get user input. Which means it's an interactive script, and the direct non-GUI equivalent is a TUI. Which means the script is not something that you will be automating for, but more just of a convenient interactive tool.
And by definition TUIs are an inferior version of a GUI, for example it usually won't handle terminal size changes, localization, etc... So it makes plenty of sense to make that a GUI for the sake of having a better input. (And I won't call that 'modernization', but it's a better option than presenting a calendar UI from your bash script or having me input a unix timestamp or something else.)
So then you might say that hey the command line equivalent of that GUI input is flags, not interactive input, but well you can make a CLI that gets it's parameters from flags and gracefully fallback to interactive input if you don't have sufficient information.
(And no, TUIs are not more efficient than GUIs. CLIs might be, because of shell piping and it's automation techniques. But TUIs are inferior, full stop.)
Please, show some humanity: think of the techies.
Nope.
I am a scripter. I will never get tired of raw text, but I sure get tired of GUIs, fast. If the author had pitched this as a way to make the scripter's scripts accessible to others who do not understand scripts, I would have a different response.
When your script was a bash script chances are you targeted proficient users with it. These might get annoyed by popping up stuff. This means ultimately you are probably better off adding a GUI and a --headless flag so both user categories are happy.
As I see it the only thing that is a little useful are the notifications (e.g. if you have some sort of daemon running in background that needs to bring sth to the users attention)
On Linux you can use `notify-send "title" "content"`. The only limitation it has is that you can't query the notification id to update or selectively dismiss it later.
Also, many terminals will have a visual alert instead/together with a sound: konsole does this, for instance.
I block cookies using a local proxy. I cannot rely on Chrome "features" for anything privacy-related. They just keep changing.
In this case: https://archive.md/Fvxy4
I doubt HN wants to get into the business of running official campaigns against publishing platforms.
Besides, isn't programming with syntax highlighting pretty much ubiquitous? Since, at this point in history, all programming I'm aware of boils down to a relatively practical application of maths, I'd argue colored blocks have already pretty much supplanted pencil and paper as the interface adults use to get stuff done.
I remember having to use TI-83 for school. Back then, some people taught the same about the calculator.
Also, sounds like you'd oppose syntax highlighting. I like making e.g. my PS1 colorful. The problem is when other's force their color scheme upon you, like mIRC colors, or website themes (!!).
Most developers like color-coded syntax highlighting in their IDEs and editors though?