Team LiB
Previous Section Next Section

Hack 38. Start Applications in Weird and Wonderful Ways

Start your applications in customized ways to make your programs run exactly how you want them to.

With modern desktop environments, starting applications is a straightforward conceptyou either click an application icon or you type in the name of a program. Simple. But if you look under the hood of this simplicity, you'll find a number of tricks and techniques for starting applications in clever and interesting ways. This hack shows you how to make an application start on a particular virtual desktop, load into a particular mode, always appear on top of other applications, or load in full-screen mode.

5.5.1. Starting Programs in KDE

An interesting facility in KDE is a tool called kstart. This simple command-line program is used to customize how programs start and display on your screen. kstart provides several options that enable you to choose which virtual desktop it appears on, if it starts as a maximized/minimized window, if it has focus and other uses.

As kstart is a command-line tool, you can experiment with it from a command-line terminal, such as a konsole, xterm, or gnome terminal. To use kstart, specify the options that determine how the application is started, and then specify the program name.

To begin with, you can experiment with how you can start applications on different virtual desktops. As an example, if you wanted to start Konqueror on virtual desktop 2, you could use this:

foo@bar:~$ kstart --desktop 2 konqueror

This command uses the --desktop option in kstart with the parameter 2 to specify the virtual desktop on which to start the application. To make Konqueror start on all the virtual desktops (particularly useful for applications that should be visible in all parts of the desktop), use the -alldesktops option:

foo@bar:~$ kstart --alldesktops konqueror

To extend this functionality a little further, combine the --alldesktops option and the --ontop option to ensure that a specific application always remains visible on every desktop. This is handy for media players such as noatun when you want to control the player at all times:

foo@bar:~$ kstart --alldesktops --ontop noatun

Another useful modification is to not display the application on the taskbar (the part of the panel that shows which programs are running). You can use the --skiptaskbar option to give the effect of a floating application that is always on top:

foo@bar:~$ kstart --alldesktops --ontop --skiptaskbar noatun

A final useful switch is the --fullscreen option. This is particularly handy when running an application that should appear like a kiosk [Hack #43] . The benefit of this mode is that you can restrict users from using other applications in kiosk mode. You can run Konqueror in full-screen mode so that it gives you a full-screen kiosk web browser:

foo@bar:~$ kstart --fullscreen konqueror

5.5.2. Adding Application Options

In addition to the facilities available in kstart, you can also combine the options and switches from the program you are running. Each Linux program has accessible options similar to the ones you used in kstart, and you can view them in the application manpage. Many programs also have a --help option that will list the different options available:

foo@bar:~$ kstart --help

As an example of combining these options, you can load Konqueror full screen in web-browsing mode to look at the O'Reilly web site:

foo@bar:~$ kstart --fullscreen konqueror --profile webbrowsing

In this example you use the --profile option in Konqueror to set the mode of the application to webbrowsing. You also specify the URL of the O'Reilly web site as the site to be loaded into Konqueror when the application starts. It is important to note that the kstart options (--fullscreen) are to the right of the kstart command and the Konqueror options (--profile webbrowsing are to the right of the konqueror command.

5.5.3. Starting Programs Conveniently

Although you have been typing your kstart commands into a terminal, you can actually use a desktop icon to run the commands. To do this, add a shortcut by right-clicking the desktop and selecting New Shortcut. In the command box, add the full kstart command. Click OK and your shortcut is complete.

Another useful feature in KDE is that you can automatically start applications when the desktop loads. This feature is useful if you use the same programs day in day out and you want them started whenever you load the desktop. If you want to load KMail, Mozilla, the Gimp, Bluefish, and Kopete when you start KDE, this feature saves you from having to click all the program icons each time the environment starts and move the application windows to your preferred desktops.

To do this, use the Autostart directory in ~/.kde. You can access the directory in Konqueror and create normal application shortcut icons inside it by dragging the programs to run into the directory. If you combine the features of kstart with the Autostart directory, you can enable your desktop to start up exactly how you want it to with the right applications running in the right part of the desktop.

    Team LiB
    Previous Section Next Section