Power Up Linux GUI Apps

Save time and gain functionality by starting your GUI apps from the command line.

Windowing interfaces to Linux have lots of advantages. Once you find the programs you need, the menus and dialog boxes list your choices, and there’s often not much else to know about the interface.

One big disadvantage of GUI apps, though, is that you’re mostly limited to whatever the interface lets you do — unless you want to re-code the interface yourself, that is. For instance, how can you use a photo viewer to see all of the photos you put in various places on your disk this past Monday? If you know where the photos are stored and what their names are, you can navigate through your directories in a file browser like Nautilus, clicking on files to view them. But what a pain!

Linux users have more choices. You can start most GUI apps from the command line with a list of arguments (usually filenames) to work on. This lets you marry the handy features of shells (filename completion, wildcards, loops and more), and well as the power of utilities like find and grep, to the GUI apps you’re already using. The command line also often lets you specify options that aren’t available from menus.

Let’s start with a couple of examples. You’d like to use GIMP to edit the photo files with rome in their filenames — like rome12.jpg and elsa in rome.jpg. Start GIMP this way:

$ gimp *rome*.jpg

You have photos of Rome in some of your 100 subdirectories but you aren’t sure which. You’d like to view them all with Eye of GNOME. Let find or the shell find the files and give their pathnames to eog:

$ eog $(find . -name '*rome*.jpg' -print)
$ eog **/*rome*.jpg

The second example above works in Z Shell and in bash version 4 with the globstar shell option set. (** is a recursive wildcard operator. To learn more, read Even Wilder Wildcards.)

Building the Command Line

The first word on a command line is usually the name of a program you want to run, like konqueror. It may be a different name than you see on your desktop menus — such as eog.

Next you can add options. Each option starts with a space and one or two dashes. For a list, use the man command or try the program’s --help option:


$ man konqueror
No manual entry for konqueror
$ konqueror --help
Usage: konqueror ... [options] [URL]
...description of each option...

From those, you should get an idea of how to build the command line. If not, and the application doesn’t do anything dangerous (like removing files), you can also just experiment. For instance, although Konqueror says it wants a single URL, it accepts filenames (and wildcards); they’ll open in tabs, one per file. These usually come last on a command line. For example, to open all filenames ending in .html within an 800×600-pixel window at the bottom right corner of the display:

$ konqueror --geometry 800x600-0-0 *.html

When you start a GUI application from the command line, its window should open fairly soon. If you get another shell prompt (like $), the app is running independently of the shell. If you don’t get another prompt, the shell is waiting for the app to finish. In that case, you can add a final ampersand (&) to run the process in the background and get another prompt:

$ gimp [abc]*tif &
[1] 1234
$

Shell and utilities give lots of flexibility; we’ll have to settle for just a few examples. The Linux Magazine Power Tools columns have more ideas.

Next: Argument Lists and Loops

Comments on "Power Up Linux GUI Apps"

cmsps

There are backslashes missing from some of the examples

Reply
jp

@cmsps, thanks for catching that. I found one missing backslash in the next-to-last example on page 2, here:

$ find . -type d -name lib -okdir nautilus \'{}\' \\;

and one more in the last example, here:

> xargs -d \'\\n\' -L 1 -p nautilus

Any others?

Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>