Total Hit Counter

Starting a program from GUI


Try MC it is extremely very good for GUI in Ubuntu and Debian 


Midnight Commander (MC)

Midnight Commander (MC) is a GNU "Swiss army knife" for the Linux console and other terminal environments. This gives newbie a menu driven console experience which is much easier to learn than standard Unix commands.
You may need to install the Midnight Commander package which is titled "mc" by the following.
$ sudo apt-get install mc
Use the mc(1) command to explore the Debian system. This is the best way to learn. Please explore few interesting locations just using the cursor keys and Enter key.
  • "/etc" and its subdirectories
  • "/var/log" and its subdirectories
  • "/usr/share/doc" and its subdirectories
  • "/sbin" and "/bin"

1.3.1. Customization of MC

In order to make MC to change working directory upon exit and cd to the directory, I suggest to modify "~/.bashrc" to include a script provided by the mc package.
. /usr/lib/mc/mc.sh
See mc(1) (under the "-P" option) for the reason. (If you do not understand what exactly I am talking here, you can do this later.)

1.3.2. Starting MC

MC can be started by the following.
$ mc
MC takes care of all file operations through its menu, requiring minimal user effort. Just press F1 to get the help screen. You can play with MC just by pressing cursor-keys and function-keys.
[Note]Note
In some consoles such as gnome-terminal(1), key strokes of function-keys may be stolen by the console program. You can disable these features by "Edit" → "Keyboard Shortcuts" for gnome-terminal.
If you encounter character encoding problem which displays garbage characters, adding "-a" to MC's command line may help prevent problems.
If this doesn't clear up your display problems with MC, see Section 9.6.6, “The terminal configuration”.

1.3.3. File manager in MC

The default is two directory panels containing file lists. Another useful mode is to set the right window to "information" to see file access privilege information, etc. Following are some essential keystrokes. With the gpm(8) daemon running, one can use a mouse on Linux character consoles, too. (Make sure to press the shift-key to obtain the normal behavior of cut and paste in MC.)
Table 1.11. The key bindings of MC
keykey binding
F1help menu
F3internal file viewer
F4internal editor
F9activate pull down menu
F10exit Midnight Commander
Tabmove between two windows
Insert or Ctrl-Tmark file for a multiple-file operation such as copy
Deldelete file (be careful---set MC to safe delete mode)
Cursor keysself-explanatory

1.3.4. Command-line tricks in MC

  • cd command changes the directory shown on the selected screen.
  • Ctrl-Enter or Alt-Enter copies a filename to the command line. Use this with cp(1) and mv(1) commands together with command-line editing.
  • Alt-Tab shows shell filename expansion choices.
  • One can specify the starting directory for both windows as arguments to MC; for example, "mc /etc /root".
  • Esc + n-key → Fn (i.e., Esc + 1 → F1, etc.; Esc + 0 → F10)
  • Pressing Esc before the key has the same effect as pressing the Alt and the key together.; i.e., type Esc + c for Alt-CEsc is called meta-key and sometimes noted as "M-".

1.3.5. The internal editor in MC

The internal editor has an interesting cut-and-paste scheme. Pressing F3 marks the start of a selection, a second F3 marks the end of selection and highlights the selection. Then you can move your cursor. If you press F6, the selected area is moved to the cursor location. If you press F5, the selected area is copied and inserted at the cursor location. F2 saves the file. F10 gets you out. Most cursor keys work intuitively.
This editor can be directly started on a file using one of the following commands.
$ mc -e filename_to_edit
$ mcedit filename_to_edit
This is not a multi-window editor, but one can use multiple Linux consoles to achieve the same effect. To copy between windows, use Alt-F<n> keys to switch virtual consoles and use "File→Insert file" or "File→Copy to file" to move a portion of a file to another file.
This internal editor can be replaced with any external editor of choice.
Also, many programs use the environment variables "$EDITOR" or "$VISUAL" to decide which editor to use. If you are uncomfortable with vim(1) or nano(1) initially, you may set these to "mcedit" by adding the following lines to "~/.bashrc".
export EDITOR=mcedit
export VISUAL=mcedit
I do recommend setting these to "vim" if possible.
If you are uncomfortable with vim(1), you can keep using mcedit(1) for most system maintenance tasks.

1.3.6. The internal viewer in MC

MC is a very smart viewer. This is a great tool for searching words in documents. I always use this for files in the "/usr/share/doc" directory. This is the fastest way to browse through masses of Linux information. This viewer can be directly started using one of the following commands.
$ mc -v path/to/filename_to_view
$ mcview path/to/filename_to_view

1.3.7. Auto-start features of MC

Press Enter on a file, and the appropriate program handles the content of the file (see Section 9.5.11, “Customizing program to be started”). This is a very convenient MC feature.
Table 1.12. The reaction to the enter key in MC
file typereaction to enter key
executable fileexecute command
man filepipe content to viewer software
html filepipe content to web browser
"*.tar.gz" and "*.deb" filebrowse its contents as if subdirectory

In order to allow these viewer and virtual file features to function, viewable files should not be set as executable. Change their status using chmod(1) or via the MC file menu.

1.3.8. FTP virtual filesystem of MC

MC can be used to access files over the Internet using FTP. Go to the menu by pressing F9, then type "p" to activate the FTP virtual filesystem. Enter a URL in the form "username:passwd@hostname.domainname", which retrieves a remote directory that appears like a local one.



Starting a program from GUI

You can set up to start a process from graphical user interface (GUI).
Under GNOME desktop environment, a program can be started with proper argument by double-clicking the launcher icon, by drag-and-drop of a file icon to the launcher icon, or by "Open with …" menu via right clicking a file icon. KDE can do the equivalent, too.
Here is an example under GNOME to create a launcher icon for mc(1) started in gnome-terminal(1).
Create an executable program "mc-term" by the following.
# cat >/usr/local/bin/mc-term <<EOF
#!/bin/sh
gnome-terminal -e "mc \$1"
EOF
# chmod 755 /usr/local/bin/mc-term
Create a desktop launcher as the following.
  1. Right click desktop space to select "Create Launcher …".
  2. Set "Type" to "Application".
  3. Set "Name" to "mc".
  4. Set "Command" to "mc-term %f".
  5. Click "OK".
Create an open-with association as as the following.
  1. Right click folder to select "Open with Other Application …".
  2. Click open "Use a custom command" dialog and enter "mc-term %f".
  3. Click "Open".

No comments: