<para>&amarok; uses keyboard shortcuts like most other applications, below is a listing of those shortcuts and there respective actions. The global shortcuts can be configured by right clicking the Player window and selecting <guimenuitem>Configure Global Shortcuts...</guimenuitem> The &amarok; shortcuts can be configured by right clicking the Player window and selecting <guimenuitem>Configure Shortcuts...</guimenuitem></para>
<tip><para>You can assign you multimedia keys to work as &amarok; shortcuts making your keyboard an &amarok; control center.</para></tip>
<para>The DCOP interface for Amarok has many generic calls that may be found in other TDE applications. This section is divided into six tables and is intended to describe the DCOP calls of the collection, contextbrowser, player, playlist, playlistbrowser and scripts. An example of the <quote>pause</quote> dcop call would look like:</para>
<entry>Returns a AmarokConfig configuration entry value from the given key.</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</sect2>
</sect1>
<sect1 id="cmd-line-options">
<title>Command-line Options</title>
<para>Amarok supports the use of the standard Qt and kde command line options. Amarok also has it's own application specific options.</para>
<para>The Qt and kde options:</para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>Option</entry>
<entry>Action</entry>
</row>
</thead>
<tbody>
<row>
<entry>--help</entry>
<entry>Show help about options.</entry>
</row>
<row>
<entry>--help-qt</entry>
<entry>Show Qt specific options.</entry>
</row>
<row>
<entry>--help-kde</entry>
<entry>Show KDE specific options.</entry>
</row>
<row>
<entry>--help-all</entry>
<entry>Show all options.</entry>
</row>
<row>
<entry>--author</entry>
<entry>Show author information.</entry>
</row>
<row>
<entry>-v, --version</entry>
<entry>Show version information.</entry>
</row>
<row>
<entry>--license</entry>
<entry>Show license information.</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<para>The Amarok options:</para>
<note><para>The &amarok; options are designed to be used while &amarok; is running.</para></note>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>Option</entry>
<entry>Action</entry>
</row>
</thead>
<tbody>
<row>
<entry>-r, --previous</entry>
<entry>Skip to the previous track in the playlist.</entry>
</row>
<row>
<entry>-p, --play</entry>
<entry>Start playing current playlist.</entry>
</row>
<row>
<entry>-s, --stop</entry>
<entry>Stop playback.</entry>
</row>
<row>
<entry>--pause</entry>
<entry>Pause playback.</entry>
</row>
<row>
<entry>-f, --next</entry>
<entry>Skip to the next track in the playlist.</entry>
</row>
<row>
<entry>-a, --append</entry>
<entry>Append Files/URLs into the playlist.</entry>
</row>
<row>
<entry>-e, --enqueue</entry>
<entry>See append, available for backwards compatability.</entry>
</row>
<row>
<entry>--queue</entry>
<entry>Queue Files/URLs after the currently playing track.</entry>
</row>
<row>
<entry>-m, --toggle-playlist-window</entry>
<entry>Toggle the playlist window.</entry>
</row>
<row>
<entry>--wizard</entry>
<entry>Launch the First-run wizard.</entry>
</row>
<row>
<entry>--engine "name"</entry>
<entry>Start &amarok; with the "name" engine.</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</sect1>
<sect1 id="script-writing">
<title>Script Writing</title>
<para>Scripting allows you to extend &amarok; easily without changing the main codebase. Scripts are similar to plugins, but instead of a dedicated plugin API they use &amarok;'s DCOP interface for communication. This makes it possible to write scripts in almost any programming language, like Ruby, Python or PHP. Not only can you create scripts in classic scripting languages, but also in compiled languages like C++ or plain C. Additionally, &amarok; can notify the scripts on special events and make them react accordingly. This notification system will be explained later in this section.</para>
<sect2 id="script-bindings">
<title>Bindings</title>
<para>It is possible to write simple scripts that do not need user interaction, and it's also possible to make scripts with comfortable GUIs that act like little applications of their own. For GUI programming one of the many bindings which KDE provides can be used, for instance RubyQt, a Qt library binding for Ruby. However, it is worth noting that not every user has all available bindings installed. If you decide to use a binding, try to use one of the relatively wide spread ones (e.g. RubyQt or PyQt).</para>
<para>In order to provide some feedback when a script fails to run due to a missing dependency, please check in your script if the module you want to include really exists. If the dependency is missing, you should catch the error and show an information dialog using the "kdialog" command line tool, so that the user learns why the script fails to run.</para>
<para>This example shows how to catch a missing dependency in Ruby:</para>
<para>&amarok; provides template scripts for several languages in the <filename class="directory">scripts/templates/</filename> directory. You can use these scripts as a basis for your own scripts, and extend them with the functionality you need. You'll notice that scripting is actually quite straightforward; For instance if you know to program a bit in Python, making your own script won't take you long.</para>
</sect2>
<sect2 id="script-controlling-amarok">
<title>Controlling &amarok; With DCOP</title>
<para>Scripts can control Amarok by calling some of its DCOP functions. The easiest way to invoke a DCOP function is by using the "dcop" command line utility, which is part of every KDE distribution.</para>
<para>Here is an example for increasing the master volume:</para>
<programlisting>dcop amarok player volumeUp</programlisting>
<para>Most scripting languages allow to execute external programs, with a function like exec(). This way the "dcop" utility can be invoked easily. Here is a simple Python example:</para>
<programlisting>
import os
os.system("dcop amarok player volumeDown")
</programlisting>
</sect2>
<sect2 id="script-notifications">
<title>Notifications</title>
<para>&amarok; sends notifications to all running scripts by writing strings to their stdin channel. The script should therefore constantly monitor stdin, and react accordingly to each of the possible events. Scripts may also choose to ignore any event they don't have a use for.</para>
<para>The following notifications are sent by &amarok;:</para>
<para>Before &amarok; exits, or when the user stops a script with the Script Manager, &amarok; sends the SIGTERM signal to the script. This signal can be caught in order to do cleanup work, like saving data or configuration settings.</para>
<para>&amarok;'s Script Manager is able to install script packages that the user has downloaded from a web server. Packages are just normal tarballs (.tar), optionally compressed with bzip2 (.bz2). We strongly recommend using a filename like myscript.amarokscript.tar.bz2, so the user can easily identify the package as an Amarok script.</para>
<note><para>&amarok; 1.3 will only accept script packages with the amarokscript extension, so it is better to use it right from the start.</para></note>
<para>The tarball's content must be organized as follows:</para>
<programlisting>
myscript/
README
myscript.py (executable)
somemodule.py
foo.data
...
</programlisting>
</sect2>
<sect2 id="script-permissions">
<title>File permissions</title>
<para>The main script must have executable (+x) permissions set, while additional modules which the script loads should not be executable. To preserve the file permissions in the tarball, you should use tar with the -p flag:</para>
<note><para>&amarok; will not be able to install the script if the permissions are not correctly set.</para></note>
</sect2>
<sect2 id="script-distributing">
<title>Distributing</title>
<para>When the package is finished, you can upload it to <ulink url="http://www.kde-apps.org">www.kde-apps.org</ulink>, and add the link to the &amarok; <ulink url="http://amarok.kde.org/amarokwiki/index.php/Scripts">Wiki Scripts Page</ulink>. For the kde-apps entry you should use the <ulink url="http://kde-apps.org/index.php?xcontentmode=56">&amarok; Scripts</ulink> category.</para>