个人工具

“UbuntuHelp:HowToAddaLauncher”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
 
(未显示同一用户的4个中间版本)
第7行: 第7行:
 
* Choose Custom Application Launcher  
 
* Choose Custom Application Launcher  
 
* Fill in ''Name'', ''Command'', and ''Comment''
 
* Fill in ''Name'', ''Command'', and ''Comment''
** ''Name'' is you want to call the link, such as "Firefox" or "Gaim"
+
* ''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.
+
* ''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.
+
* ''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 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''
 
* Click ''OK''
第16行: 第16行:
 
== The Hard Way ==
 
== The Hard Way ==
 
What if this does not work?
 
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 have access to the Bash environment so you cannot just include the needed commands.
+
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).
 
Instead, you need to make a Bash script (don't worry, it's simple).
# Create a new text file somewhere on your computer. Open a terminal window and type
+
<ol><li>Create a new text file somewhere on your computer. Open a terminal window and type<pre><nowiki>
<pre><nowiki>
+
 
sudo nano /usr/local/bin/sampleprogram
 
sudo nano /usr/local/bin/sampleprogram
</nowiki></pre>  
+
</nowiki></pre>
# Fill the new file with this:
+
</li><li>Fill the new file with this:<pre><nowiki>
<pre><nowiki>
+
 
#!/bin/bash
 
#!/bin/bash
 
<your command>
 
<your command>
第29行: 第27行:
 
<your command>
 
<your command>
 
</nowiki></pre>
 
</nowiki></pre>
# Press Control+X to save your file & exit Nano.
+
</li><li>Press Control+X to save your file & exit Nano.
# Make the file executable by typing the following in the terminal:
+
</li><li>Make the file executable by typing the following in the terminal:<pre><nowiki>
<pre><nowiki>
+
 
sudo chmod +x /usr/local/bin/sampleprogram
 
sudo chmod +x /usr/local/bin/sampleprogram
 
</nowiki></pre>
 
</nowiki></pre>
# 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:
+
</li><li>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:<pre><nowiki>
<pre><nowiki>
+
 
sudo updatedb
 
sudo updatedb
</nowiki></pre>
+
</nowiki></pre></li></ol>
 +
 
 
=== Examples of Bash scripts ===
 
=== Examples of Bash scripts ===
 
Here are a few other examples of Bash scripts:
 
Here are a few other examples of Bash scripts:
第43行: 第40行:
 
#/bin/bash
 
#/bin/bash
 
WINEDLLOVERRIDES=\"ole32,usp10,msvcrt=n\"
 
WINEDLLOVERRIDES=\"ole32,usp10,msvcrt=n\"
wine $HOME/.wine/drive_c/Program\ Files/Google/Google\ Earth/[[UbuntuHelp:GoogleEarth|GoogleEarth]].exe
+
wine $HOME/.wine/drive_c/Program\ Files/Google/Google\ Earth/GoogleEarth.exe
 
</nowiki></pre>
 
</nowiki></pre>
 
<pre><nowiki>
 
<pre><nowiki>
第51行: 第48行:
 
</nowiki></pre>
 
</nowiki></pre>
 
----
 
----
[[category:CategoryDocumentation]]
 
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2009年5月12日 (二) 17:10的最新版本

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