GUI for bash commands

Hi,
I have a large collection of commands which I use in console bash to transform pdf, png, etc., like pdftk in.pdf cat 1 5 7 10-12 output out.pdf, for example, to extract specific pages from pdf file. I made some sh executable files which make automatically some of these commands. But there become so many of them that I was already confused. Is it possible (and useful?) to make a GUI interface by using Racket, for all these commands with choice possibilities and launch them in the console? If yes - what package is suitable for this aim?

1 Like

Are these commands parameterized (as in: you need some text fields in the GUI), or are they fully specified, like the one you give?

If they are fully specified, you could use a search-list-box.
For example:

#lang racket
(require search-list-box)

(define my-commands
  '(["echo" "a"]
    ["echo" "b" "c"]))

(new search-list-box-frame%
     [label "My commands"]
     [contents my-commands]
     [callback (λ (idx lbl content)
                 (apply system* "/usr/bin/env" content))])

No, the commands are not fully specified. For example, in command pdftk in.pdf cat p1-p2 output out.pdf I'd like to take the possibility of choosing in.pdf, out.pdf, and pages p1 and p2. I'd like to make something like: in the menu - "extract interval of pages", by clicking on it the submenu appears with places for choosing in the file output file and selecting pages.

Then the callback could be opening a new command-dependent dialog% that asks for the relevant info/fields, with ok/cancel buttons, and run the command of ok.

Maybe take a look at gui-easy for this part.

1 Like

Here's an example which may help:

It is a GUI front end to the popular command line video editing tool FFMPEG. You sometimes have to put together a pretty long command string to use FFMPEG so it's popular to write various kinds of scripts and GUI interfaces which construct these commands for you. In the past, I have used shell script, Perl, Applescript, and now Racket for this purpose. Applescript is very convenient, in many cases, because it provides an easy way to construct droplets where you just drag and drop files to have your script do its thing to all the files. Racket, as in my example linked above, is really good for producing an interactive GUI to do similar things. I wrote this in Racket a while back when there wasn't a simple alternative that I could find for what this program does. Since then the popular video processing utility HandBrake added similar functionality so there hasn't been much motivation to improve my version.

Note that Process_with_FFMPEG.rkt is using the mrlib/terminal package in order to show you the command as it's running. It is also using my GUI-helpers package which I am in the process of splitting up into two packages, big-widgets and easy-menus, but I plan to keep GUI-helpers as a pointer to the two new packages so it's okay to go ahead and use it as-is.

James