Advanced Amarok features Keyboard Shortcuts &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 Configure Global Shortcuts... The &amarok; shortcuts can be configured by right clicking the Player window and selecting Configure Shortcuts... You can assign you multimedia keys to work as &amarok; shortcuts making your keyboard an &amarok; control center. The global shortcuts are: Key Combination Action WinX Play WinC Pause WinV Stop WinB Next Track WinZ Previous Track WinKP_Add Increase Volume WinKP_Subtract Decrease Volume WinShiftKP_Add Seek Forward WinShiftKP_Subtract Seek Backward WinA Add Media WinP Toggle Playlist WinO Show OSD WinM Mute Volume The &amarok; shortcuts are: Key Combination Action CtrlC Copy CtrlKP_Enter Goto Current CtrlD Queue Selected Tracks CtrlQ Quit CtrlShiftZ Redo CtrlS Save Playlist CtrlA Select All CtrlM Show Menubar CtrlH Shuffle CtrlZ Undo The Playlist Browser shortcuts are: Key Combination Action Space Load Playlist F2 Rename Playlist Backspace Remove Playlist The DCOP Interface The Amarok DCOP interface provides you with an easy way to control Amarok with your own custom scripts. 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 pause dcop call would look like: %dcop amarok player pause dcop amarok collection DCOP Call Action int totalAlbums() Returns the total of albums in the collection. int totalArtists() Returns the total of artists in the collection. int totalCompilations() Returns the total of compilations in the collection. int totalGenres() Returns the total of genres in the collection. int totalTracks() Returns the total of tracks in the collection. TQString query( TQString sql) Queries the database via SQL. QStringList similarArtists( int artists ) Return similar artists of the current tracks, limit to int artists. void migrateFile( TQString oldURL, TQString newURL ) Move a file in the collection, keeping stats intact. void scanCollection() Scan the collection. void scanCollectionChanges() Scan the collection for changes only. dcop amarok contextbrowser DCOP Call Action void showCurrentTrack() Show the current track in the context browser. void showLyrics() Show the lyrics tab in the context browser. void showWiki() Show the wikipedia tab in the context browser. dcop amarok player DCOP Call Action bool dynamicModeStatus() Return dynamic mode status. bool equalizerEnabled() Return the equalizer status. bool isPlaying() Return true if something is playing now. bool randomModeStatus() Return random mode status. bool repeatPlaylistStatus() Return repeat playlist status. bool repeatTrackStatus() Return repeat track status. int getVolume() Return volume in range 0-100%. int sampleRate() Return the sample rate of the currently playing track. int score() Return the score of the currently playing track. int status() Return playback status: 0 - stopped, 1 - paused, 2 - playing. int trackCurrentTime() Return current play position in seconds. int trackPlayCounter() Return play counter for current song. int trackTotalTime() Return track length in seconds. TQString album() Return the album of the currently playing track. TQString artist() Return the artist of the currently playing track. TQString bitrate() Return the bitrate of the currently playing track (XX kbps). TQString comment() Return the comment of the currently playing track. TQString coverImage() Return the encoded URL of the current track's cover image TQString currentTime() Return the position of the currently playing track ([h:]mm:ss format). TQString encodedURL() Return the encoded URL of the currently playing track. TQString engine() Return the current sound engine. TQString genre() Return the genre of the currently playing track. TQString lyrics() Return the lyrics of the currently playing track. TQString lyricsByPath( TQString path ) Return the lyrics of a track by path. TQString nowPlaying() The title of now playing media. TQString path() Return the unencoded path of the currently playing track. TQString setContextStyle( TQString ) Set the CSS style for the context browser. TQString title() Return the title of the currently playing track. TQString totalTime() Return the total length of the currently playing track ([h:]mm:ss format). TQString track() Return the track number. TQString type() Return the file type. TQString year() Return the year of the currently playing track. void configEqualizer() Toggle equalizer config dialog. void enableDynamicMode(bool enable) Switch Dynamic Mode on or off. void enableOSD(bool enable) Switch OSD display on or off. void enableRandomMode(bool enable) Switch Random Mode on or off. void enableRepeatPlaylist(bool enable) Switch Repeat Playlist on or off. void enableRepeatTrack(bool enable) Switch Repeat Track on or off. void mediaDeviceMount() Sets the command used for mounting media device. void mediaDeviceUmount() Sets the comment used for umounting media device. void mute() Toggle mute. void next() Equivalent to pressing "Next" button. void pause() Equivalent to pressing "Pause" button. void play() Equivalent to pressing "Play" button. void playPause() Toggle play/pause state (good for mm keyboard users) void prev() Equivalent to pressing "Prev" button. void queueForTransfer( KURL url ) Queue file for transfer to Media Device. void seek(int s) Seek track to seconds position. void seekRelative(int s) Seek to a position relative to the current track position. void setEqualizer(int, int, int, int, int, int, int, int, int, int, int) Set the equalizer bands void setEqualizerEnabled( bool active ) Toggle equalizer. void setEqualizerPreset( TQString name ) Set the equalizer preset void setLyricsByPath( TQString url, TQString lyrics ) Set the lyrics of a track by it's path. void setScore( int score ) Set the score of the currently playing track. void setScoreByPath( TQString url, int score ) Set the score of a track by it's path. void setVolume(int volume) Set volume in range 0-100%. void showBrowser( TQString browser ) Shows browsers in the playlist window void showOSD() Show the OSD display on the screen. void stop() Equivalent to pressing "Stop" button. void transferDeviceFiles() Transfer files to media device. void volumeDown() Decrease volume by a reasonable step. void volumeUp() Increase volume by a reasonable step. dcop amarok playlist DCOP Call Action int getActiveIndex() Return the index of the currently active track. -1 if none. int getTotalTrackCount() Return number of tracks in playlist. 0 if none. TQString saveCurrentPlaylist() Saves the current playlist to current.xml and returns its path. void addMedia( KURL ) Add audio media specified by the url. void addMediaList( KURL::List ) Add some audio media specified by the url. void clearPlaylist() Clears the playlist. void playByIndex(int) Starts playing the track at the specified index. void playMedia( KURL ) Add audio media specified by the url. void popupMessage( TQString) Shows a temporary popup message. void removeCurrentTrack() Removes the current-track item from the playlist. void repopulate() Repopulate the playlist with random tracks. void saveM3u( TQString path, bool relativePaths) Saves the current playlist as m3u. void setStopAfterCurrent( bool ) Enables/disables the "Stop After Current Track" feature. void shortStatusMessage( TQString) Shows a temporary message on the statusbar. void shufflePlaylist() Shuffles the playlist. void togglePlaylist() Toggle the Playlist-window. dcop amarok playlistbrowser DCOP Call Action void addPodcast( TQString ) Add a podcast entry to the playlist browser. void scanPodcasts() Scan all podcasts for updates. void addPlaylist( TQString ) Add a playlist to the playlist browser. dcop amarok script DCOP Call Action bool runScript( TQString name) Starts the script with the given name. Returns true on success. bool stopScript( TQString name) Stops the script with the given name. Returns true on success. QStringList listRunningScripts() Returns a list of all currently running scripts. void addCustomMenuItem(TQString submenu, TQString itemTitle ) Enables and sets custom menu item title. void removeCustomMenuItem(TQString submenu, TQString itemTitle ) Removes the custom menu item. TQString readConfig( TQString key) Returns a AmarokConfig configuration entry value from the given key. Command-line Options Amarok supports the use of the standard Qt and kde command line options. Amarok also has it's own application specific options. The Qt and kde options: Option Action --help Show help about options. --help-qt Show Qt specific options. --help-kde Show KDE specific options. --help-all Show all options. --author Show author information. -v, --version Show version information. --license Show license information. The Amarok options: The &amarok; options are designed to be used while &amarok; is running. Option Action -r, --previous Skip to the previous track in the playlist. -p, --play Start playing current playlist. -s, --stop Stop playback. --pause Pause playback. -f, --next Skip to the next track in the playlist. -a, --append Append Files/URLs into the playlist. -e, --enqueue See append, available for backwards compatability. --queue Queue Files/URLs after the currently playing track. -m, --toggle-playlist-window Toggle the playlist window. --wizard Launch the First-run wizard. --engine "name" Start &amarok; with the "name" engine. Script Writing 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. Bindings 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). 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. This example shows how to catch a missing dependency in Ruby: begin require 'Korundum' rescue LoadError error = 'Korundum (KDE bindings for ruby) from tdebindings v3.4 is required for this script.' `kdialog --sorry '#{error}'` exit end Getting Started: The Templates &amarok; provides template scripts for several languages in the scripts/templates/ 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. Controlling &amarok; With DCOP 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. Here is an example for increasing the master volume: dcop amarok player volumeUp 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: import os os.system("dcop amarok player volumeDown") Notifications &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. The following notifications are sent by &amarok;: configure Tells the script to show its configuration dialog. The script must handle the storing and loading of configuration options by itself. When a script is started, Amarok sets its working directory to the folder where all data should be stored. engineStateChange:empty|idle|paused|playing Signals a change in the engine's state. trackChange Signals the start of a new track. The script may then use DCOP functions to query further information about the track, e.g. metadata and the length. volumeChangenewVolume Signals a change of the master volume level. The volume is an integer with a range of 0-100. customMenuClicked:submenu itemTitle paths Returns the paths to selected files in the playlist when the custom playlist context menu item is clicked. The submenu and itemTitle are also returned for identification purposes in case a script is listening for multiple notifications. To insert an item into the context menu use the DCOP call 'dcop amarok script addCustomMenuItem( submenu itemTitle )'. To remove an item from the context menu use the DCOP call 'dcop amarok script removeCustomMenuItem( submenu itemTitle )'. Script Termination 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. Packaging &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. &amarok; 1.3 will only accept script packages with the amarokscript extension, so it is better to use it right from the start. The tarball's content must be organized as follows: myscript/ README myscript.py (executable) somemodule.py foo.data ... File permissions 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: tar -cf myscript.amarokscript.tar -p myscript &amarok; will not be able to install the script if the permissions are not correctly set. Distributing When the package is finished, you can upload it to www.kde-apps.org, and add the link to the &amarok; Wiki Scripts Page. For the kde-apps entry you should use the &amarok; Scripts category.