个人工具

UbuntuHelp:HowToAddaLauncher

来自Ubuntu中文

跳转至: 导航, 搜索

Launchers are similar to "shortcuts" in Windows or "aliases" in the Mac OS. Adding a launcher in Ubuntu is easy.

The Easy Way

  • Right-click unused space in any panel (the toolbars at the top and/or bottom of the screen)
  • Choose Add To Panel...
  • Choose Custom Application Launcher
  • Fill in Name, Command, and Comment
  • Name is you want to call the link, such as "Firefox" or "Gaim"
  • Command is what you would type in the terminal to launch the program. You can also click the "Browse" button to find the program on your computer.
  • Comment is for a short explanation of the program. This and the Name will appear when you hover your mouse over the launcher.
  • Click the No Icon button to select an icon for your launcher. You may find icons in /usr/share/icons/crystalsvg/16x16/apps/ or elsewhere. You could also make them yourself using GIMP or any other graphic editor.
  • Click OK
  • Your launcher should now appear on the panel

You may also find directions on adding launchers in Ubuntu's built-in help. From the System menu select "Help and Support" then "Customising Your Desktop > Cutomising Panels > Launchers."

The Hard Way

What if this does not work? Some programs need additional commands before they can be started. Java programs need to be started from within the directory in which their files exist. Others must be run within Wine. Unfortunately launchers do not have access to the Bash environment so you cannot just include the needed commands. Instead, you need to make a Bash script (don't worry, it's simple).

  1. Create a new text file somewhere on your computer. Open a terminal window and type
    sudo nano /usr/local/bin/sampleprogram
    
  2. Fill the new file with this:
    #!/bin/bash
    <your command>
    <your command>
    <your command>
    
  3. Press Control+X to save your file & exit Nano.
  4. Make the file executable by typing the following in the terminal:
    sudo chmod +x /usr/local/bin/sampleprogram
    
  5. In the Create Launcher window, fill Command with /usr/local/bin/sampleprogram (or just sampleprogram, but be sure to update your database before that by typing the following in the terminal:
    sudo updatedb
    

Examples of Bash scripts

Here are a few other examples of Bash scripts:

#/bin/bash
WINEDLLOVERRIDES=\"ole32,usp10,msvcrt=n\"
wine $HOME/.wine/drive_c/Program\ Files/Google/Google\ Earth/GoogleEarth.exe
#!/bin/bash
cd $HOME/Movietheque/
$HOME/Movietheque/Movietheque.run