Tool to create UI for Linux (Gnome) shell scripts - linux

I'm writing a bunch of Linux shell scripts with complex selections. For now I use zenity for prompts. I'd rather use something where I can show more than one UI element at a time and query it in a script (e.g. a list and some checkboxed and a file picker and an entry field.
What are my options?

I believe GTKDialog comes with extended gtk-ified versions of the popular curses based dialog utility for shell scripts.
I'm not sure if it will serve the complexity of your needs, however. In any event, its a place to start.

You're going to have to move up to something more capable. PyGTK with Glade is fairly powerful, and Python is easy enough to pick up.

autoglade could also be of help to give your scripts of commands a graphical user interface, in many cases with no additional programming.
Some docs and tutorials can be found here.

zenity 3 now has a option to create a form with multiple elements. See the following bug report
https://bugzilla.gnome.org/show_bug.cgi?id=412493

Yad is a fork of Zenity that adds almost as much functionality as Gtkdialog. Mostly backward compatible too.

Related

Pretty shell script (menus, images, antialias, 1080p, colors, fade effects etc.)?

I've created a couple of very simple bash scripts for a home-made games arcade (input configuration, updating stuff etc). I've got a launcher, so it's not a problem to direct the user to run the wanted shell script, but while running a bash script functionality-wise gives me everything I need, the default low-res text-on-black look scares the end user.
What is the simplest way to "prettify" fullscreen shell scripts? Something that'll run the script in 1080p, use bigger bubbly antialiased fonts, add a fancy animated background etc., but still pretty much lets me stick to write good-old shell scripts?
I guess another way to ask is: Does a prettier, more modern GUI-looking alternative to whiptail exist?
I am running from the terminal, so the GUI library it would have to be as fully self-contained as possible.
The ability of a shell script to display a quit within the terminal window itself is limited entirely to the graphical capabilities of the terminal (and to what termcap/terminfo has support for).
Most terminals max out at 256 colors (though supposedly konsole has support for arbitrary RGB colors somehow).
Control over font sizing/etc. from the shell is limited to the escape sequences that the terminal is willing to respond to (and I don't know if those are at all standard or discoverable at runtime).
The best option for this might be to have your script re-exec itself in a new terminal window to which it passes appropriate arguments to control font selection, window geometry, color selection, etc.
That being said even reliably doing that isn't necessarily the easiest thing in the world (I'm not sure how portable the command line options are between different terminal emulators or how many more advanced features they expose).
You could use python with the library Gooey that makes easy to turn CLI applications to GUI:
It can be customized and it takes only one line for the magic to happen:
from gooey import Gooey
#Gooey <--- all it takes! :)
def main():
# rest of code

DDE/IPC in linux gui?

There used to be Dynamic Data Exchange API (type of IPC) in windows which allowed sending notifications with params to running process and they would grab focus and conduct the operation. Is there anything similar in xwindows/gnome?
Like for example, when I get my phpunit errors, it comes with file path and line number. Was wondering if using any bash script or perl etc, I could grab the output and make the line below clickable
protected/tests/controllers/CmsControllerTest.php:17
so it quickly focus on my eclipse, open the file and moves cursor to the right line number.
phpunit and eclipse is just for examples. enough said.
The usual way to address this, would be to make the functionality an eclipse plugin.
There are lots of examples on how to write such plugins.
Moreover, you can probably lean on/reuse rather feature complete existing views (Problems view, Tasks view etc.) so making it look beautiful and matching eclipse should be a breeze.
Alternatively, there is a rich API that you could use to implement your own IPC channel to talk with your test runner outside Eclipse. An example of that is eclimd, the Vim-eclipse integration thing. Specifically, look at it's behaviour in 'Headed Eclipse' mode.

Tutorial/Guide to create a classic, small Linux application in a package (Debian)

I've made a small script in my machine, and an alias in .bashrc that calls it. It's a bash script with 3 lines, but it can grow.
Now, some people in my team found it useful, and want to use it.
Instead of saying "copy this alias, do this, do that, install that lib" I was thinking about creating a simple package to be a little more professional. Fact is, I've never done something like this before. And the problem to me is not creating a package, is trying to decide what usually do you put in a package.
Suppose I want to take my script, and create myapplication. I want to create a .deb file that my team would install and:
Have a /usr/bin/myapplication or /usr/sbin/myapplication (what's the difference between them?), so they would just call myapplication at their terminal and it would work;
Have a man page; (Where are usually located man pages in a debian system?);
Have a possibility to read a .myapplicationrc in home folder with some configurations;
Have an entry for shortcuts in a gnome installation (is it possible to have an universal shortcut "format" that's is available to KDE and Gnome as well?);
Install dependencies.
I'm new to all that stuff. I usually code simple scripts and create an alias in my bashrc. I've never done a package before. Which guides do you know of that can help me accomplish what I thinking of above?
Here is a place to start, though I welcome a more succinct answer.
I couldn't find a complete guide. I think the best thing to do is download a package that does exactly what I'm thinking of and do some reading, like taskwarrior.

Make a Linux "GUI" in the command line

How to make a Linux program in the Command Line Interface who display a nice user interface?
For example when I use "wget" to download a file from internet, I can see the download advancement in the Command Line Interface. How can I do that?
ncurses is a popular option, there are APIs for lots of programming languages.
Take a look at curses. It is a library for text based UI.
You can get a basic interface by using \r to go to the beginning of the current line.
Slightly more advanced is ncurses.
The next step up is Newt.
If you want to do a GUI for Bash scripts or to wrap around other command line utilities, you can use dialog (man page).
Here two great dialog tutorial to get you started :
Dialog: An Introductory Tutorial
Improve Bash Shell Scripts Using Dialog.
If you only need a progress bar, this can be done directly with a simple print (that prints the bar), followed by the carriage return character (ANSI character #13), which puts you back at the beginning of the line. The line can then be later updated by printing over it.
For more complicated needs, ncurses is indeed the standard way to go.
I wouldn't call wget's progress report as a 'nice gui', but anyway, the classic library for building graphical interfaces without X Windows is Linux and UNIX systems is ncurses.
Recently a C# version of ncurses has been started, check out details here
If you're using Mono, you could use MonoCurses
Try curses, it is a well documented API for text based UI.Also, there is so much open source projects that are using curses for you see and learn
wget does not really have a GUI, all I see is stuff that you can already achieve using stdout and echos (e.g. printf() or std::cout)
Anyways, for simple dialog boxes of the MessageBox kind, but not limited to that, also have a look at dialog
http://linux.die.net/man/1/dialog
http://hightek.org/dialog/
You can just use ANSI escape codes. A simple example in bash
echo -e "\033[H\033[2J \033[20;20H \033[4mThis is a underlined line.\033[0m"
One should mention FTXUI. Functional Terminal (X) User interface: A simple C++ library for terminal-based user interfaces!
Cross-Platform
Support for UTF8 and fullwidth chars (→ 测试)
No dependencies
etc

Show last command with up arrow on a linux c shell

I have implemented a simple linux shell in c. Now, I am adding some features and one I immediately thought about was to be able to show the last commands with the up arrow.
Question 1:
However, I have no idea how to accomplish this. Do you?
Question 2:
Any comment on how to store the "history" commands are also appreciated. I suppose something like a queue which allows access to all elements would be a good idea. Am I wrong? Do I have to implement it or is there already some good implementation out there I should know about?
Thanks.
Build libedit or readline support into your shell.
If you want to be lazy, you can use rlwrap:
rlwrap prog
I wrote the shell for HelenOS. Grab the bzr repo and navigate to uspace/app/bdsh (bdsh stands for the (b)rain (d)ead (sh)ell).
Other contributors have since added line editing / history / tab completion to the functions that handle input. Its written purely in ANSI C, does not link against glibc and implements its own functions. The code (both in the shell and underlying HelenOS libc) is 3 clause BSD, you can use it in anything.
If nothing else, it might help to just examine the implementation to get started.

Resources