summaryrefslogtreecommitdiffstats
path: root/doc/amarok/advanced.docbook
blob: 9f0908eb1bb205abe30591bd0022d5d4527ebb06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
<chapter id="advanced-features">
<title>Advanced Amarok features</title>


<sect1 id="keybd-shortcuts">
<title>Keyboard Shortcuts</title>

<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 global shortcuts are:</para>

<informaltable>
<tgroup cols="2">
<thead>

<row>
<entry>Key Combination</entry>
<entry>Action</entry>
</row>
</thead>
<tbody>

<row>
<entry><keycombo><keycap>Win</keycap><keycap>X</keycap></keycombo></entry>
<entry>Play</entry>
</row>

<row>
<entry><keycombo><keycap>Win</keycap><keycap>C</keycap></keycombo></entry>
<entry>Pause</entry>
</row>

<row>
<entry><keycombo><keycap>Win</keycap><keycap>V</keycap></keycombo></entry>
<entry>Stop</entry>
</row>

<row>
<entry><keycombo><keycap>Win</keycap><keycap>B</keycap></keycombo></entry>
<entry>Next Track</entry>
</row>

<row>
<entry><keycombo><keycap>Win</keycap><keycap>Z</keycap></keycombo></entry>
<entry>Previous Track</entry>
</row>

<row>
<entry><keycombo><keycap>Win</keycap><keycap>KP_Add</keycap></keycombo></entry>
<entry>Increase Volume</entry>
</row>

<row>
<entry><keycombo><keycap>Win</keycap><keycap>KP_Subtract</keycap></keycombo></entry>
<entry>Decrease Volume</entry>
</row>

<row>
<entry><keycombo><keycap>Win</keycap><keycap>Shift</keycap><keycap>KP_Add</keycap></keycombo></entry>
<entry>Seek Forward</entry>
</row>

<row>
<entry><keycombo><keycap>Win</keycap><keycap>Shift</keycap><keycap>KP_Subtract</keycap></keycombo></entry>
<entry>Seek Backward</entry>
</row>

<row>
<entry><keycombo><keycap>Win</keycap><keycap>A</keycap></keycombo></entry>
<entry>Add Media</entry>
</row>

<row>
<entry><keycombo><keycap>Win</keycap><keycap>P</keycap></keycombo></entry>
<entry>Toggle Playlist</entry>
</row>

<row>
<entry><keycombo><keycap>Win</keycap><keycap>O</keycap></keycombo></entry>
<entry>Show OSD</entry>
</row>

<row>
<entry><keycombo><keycap>Win</keycap><keycap>M</keycap></keycombo></entry>
<entry>Mute Volume</entry>
</row>

</tbody>
</tgroup>
</informaltable>

<para>The &amarok; shortcuts are:</para>

<informaltable>
<tgroup cols="2">
<thead>

<row>
<entry>Key Combination</entry>
<entry>Action</entry>
</row>
</thead>
<tbody>

<row>
<entry><keycombo><keycap>Ctrl</keycap><keycap>C</keycap></keycombo></entry>
<entry>Copy</entry>
</row>

<row>
<entry><keycombo><keycap>Ctrl</keycap><keycap>KP_Enter</keycap></keycombo></entry>
<entry>Goto Current</entry>
</row>

<row>
<entry><keycombo><keycap>Ctrl</keycap><keycap>D</keycap></keycombo></entry>
<entry>Queue Selected Tracks</entry>
</row>

<row>
<entry><keycombo><keycap>Ctrl</keycap><keycap>Q</keycap></keycombo></entry>
<entry>Quit</entry>
</row>

<row>
<entry><keycombo><keycap>Ctrl</keycap><keycap>Shift</keycap><keycap>Z</keycap></keycombo></entry>
<entry>Redo</entry>
</row>

<row>
<entry><keycombo><keycap>Ctrl</keycap><keycap>S</keycap></keycombo></entry>
<entry>Save Playlist</entry>
</row>

<row>
<entry><keycombo><keycap>Ctrl</keycap><keycap>A</keycap></keycombo></entry>
<entry>Select All</entry>
</row>

<row>
<entry><keycombo><keycap>Ctrl</keycap><keycap>M</keycap></keycombo></entry>
<entry>Show Menubar</entry>
</row>

<row>
<entry><keycombo><keycap>Ctrl</keycap><keycap>H</keycap></keycombo></entry>
<entry>Shuffle</entry>
</row>

<row>
<entry><keycombo><keycap>Ctrl</keycap><keycap>Z</keycap></keycombo></entry>
<entry>Undo</entry>
</row>


</tbody>
</tgroup>
</informaltable>


<para>The Playlist Browser shortcuts are:</para>

<informaltable>
<tgroup cols="2">
<thead>

<row>
<entry>Key Combination</entry>
<entry>Action</entry>
</row>
</thead>
<tbody>

<row>
<entry><keycap>Space</keycap></entry>
<entry>Load Playlist</entry>
</row>

<row>
<entry><keycap>F2</keycap></entry>
<entry>Rename Playlist</entry>
</row>

<row>
<entry><keycap>Backspace</keycap></entry>
<entry>Remove Playlist</entry>
</row>

</tbody>
</tgroup>
</informaltable>

</sect1>

<sect1 id="the-dcop-interface">
<title>The DCOP Interface</title>

<para>The Amarok DCOP interface provides you with an easy way to control Amarok with your own custom scripts.</para>

<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>

<para><prompt>&percnt;</prompt>dcop amarok player pause</para>

<sect2 id="dcop-collection">
<title>dcop amarok collection</title>

<informaltable>
<tgroup cols="2">
<thead>

<row>
<entry>DCOP Call</entry>
<entry>Action</entry>
</row>
</thead>
<tbody>

<row>
<entry>int totalAlbums()</entry>
<entry>Returns the total of albums in the collection.</entry>
</row>

<row>
<entry>int totalArtists()</entry>
<entry>Returns the total of artists in the collection.</entry>
</row>

<row>
<entry>int totalCompilations()</entry>
<entry>Returns the total of compilations in the collection.</entry>
</row>

<row>
<entry>int totalGenres()</entry>
<entry>Returns the total of genres in the collection.</entry>
</row>

<row>
<entry>int totalTracks()</entry>
<entry>Returns the total of tracks in the collection.</entry>
</row>

<row>
<entry>QString query( QString sql)</entry>
<entry>Queries the database via SQL.</entry>
</row>

<row>
<entry>QStringList similarArtists( int artists )</entry>
<entry>Return similar artists of the current tracks, limit to int artists.</entry>
</row>

<row>
<entry>void migrateFile( QString oldURL, QString newURL )</entry>
<entry>Move a file in the collection, keeping stats intact.</entry>
</row>

<row>
<entry>void scanCollection()</entry>
<entry>Scan the collection.</entry>
</row>

<row>
<entry>void scanCollectionChanges()</entry>
<entry>Scan the collection for changes only.</entry>
</row>


</tbody>
</tgroup>
</informaltable>

</sect2>

<sect2 id="dcop-context">
<title>dcop amarok contextbrowser</title>

<informaltable>
<tgroup cols="2">
<thead>

<row>
<entry>DCOP Call</entry>
<entry>Action</entry>
</row>
</thead>
<tbody>

<row>
<entry>void showCurrentTrack()</entry>
<entry>Show the current track in the context browser.</entry>
</row>

<row>
<entry>void showLyrics()</entry>
<entry>Show the lyrics tab in the context browser.</entry>
</row>

<row>
<entry>void showWiki()</entry>
<entry>Show the wikipedia tab in the context browser.</entry>
</row>

</tbody>
</tgroup>
</informaltable>

</sect2>

<sect2 id="dcop-player">
<title>dcop amarok player</title>

<informaltable>
<tgroup cols="2">
<thead>

<row>
<entry>DCOP Call</entry>
<entry>Action</entry>
</row>
</thead>
<tbody>

<row>
<entry>bool dynamicModeStatus()</entry>
<entry>Return dynamic mode status.</entry>
</row>

<row>
<entry>bool equalizerEnabled()</entry>
<entry>Return the equalizer status.</entry>
</row>

<row>
<entry>bool isPlaying()</entry>
<entry>Return true if something is playing now.</entry>
</row>

<row>
<entry>bool randomModeStatus()</entry>
<entry>Return random mode status.</entry>
</row>

<row>
<entry>bool repeatPlaylistStatus()</entry>
<entry>Return repeat playlist status.</entry>
</row>

<row>
<entry>bool repeatTrackStatus()</entry>
<entry>Return repeat track status.</entry>
</row>

<row>
<entry>int getVolume()</entry>
<entry>Return volume in range 0-100%.</entry>
</row>

<row>
<entry>int sampleRate()</entry>
<entry>Return the sample rate of the currently playing track.</entry>
</row>

<row>
<entry>int score()</entry>
<entry>Return the score of the currently playing track.</entry>
</row>

<row>
<entry>int status()</entry>
<entry>Return playback status: 0 - stopped, 1 - paused, 2 - playing.</entry>
</row>

<row>
<entry>int trackCurrentTime()</entry>
<entry>Return current play position in seconds.</entry>
</row>

<row>
<entry>int trackPlayCounter()</entry>
<entry>Return play counter for current song.</entry>
</row>

<row>
<entry>int trackTotalTime()</entry>
<entry>Return track length in seconds.</entry>
</row>

<row>
<entry>QString album()</entry>
<entry>Return the album of the currently playing track.</entry>
</row>

<row>
<entry>QString artist()</entry>
<entry>Return the artist of the currently playing track.</entry>
</row>

<row>
<entry>QString bitrate()</entry>
<entry>Return the bitrate of the currently playing track (XX kbps).</entry>
</row>

<row>
<entry>QString comment()</entry>
<entry>Return the comment of the currently playing track.</entry>
</row>

<row>
<entry>QString coverImage()</entry>
<entry>Return the encoded URL of the current track's cover image </entry>
</row>

<row>
<entry>QString currentTime()</entry>
<entry>Return the position of the currently playing track ([h:]mm:ss format).</entry>
</row>

<row>
<entry>QString encodedURL()</entry>
<entry>Return the encoded URL of the currently playing track.</entry>
</row>

<row>
<entry>QString engine()</entry>
<entry>Return the current sound engine.</entry>
</row>

<row>
<entry>QString genre()</entry>
<entry>Return the genre of the currently playing track.</entry>
</row>

<row>
<entry>QString lyrics()</entry>
<entry>Return the lyrics of the currently playing track.</entry>
</row>

<row>
<entry>QString lyricsByPath( QString path )</entry>
<entry>Return the lyrics of a track by path.</entry>
</row>

<row>
<entry>QString nowPlaying()</entry>
<entry>The title of now playing media.</entry>
</row>

<row>
<entry>QString path()</entry>
<entry>Return the unencoded path of the currently playing track.</entry>
</row>

<row>
<entry>QString setContextStyle( QString )</entry>
<entry>Set the CSS style for the context browser.</entry>
</row>

<row>
<entry>QString title()</entry>
<entry>Return the title of the currently playing track.</entry>
</row>

<row>
<entry>QString totalTime()</entry>
<entry>Return the total length of the currently playing track ([h:]mm:ss format).</entry>
</row>

<row>
<entry>QString track()</entry>
<entry>Return the track number.</entry>
</row>

<row>
<entry>QString type()</entry>
<entry>Return the file type.</entry>
</row>

<row>
<entry>QString year()</entry>
<entry>Return the year of the currently playing track.</entry>
</row>

<row>
<entry>void configEqualizer()</entry>
<entry>Toggle equalizer config dialog.</entry>
</row>

<row>
<entry>void enableDynamicMode(bool enable)</entry>
<entry>Switch Dynamic Mode on or off.</entry>
</row>

<row>
<entry>void enableOSD(bool enable)</entry>
<entry>Switch OSD display on or off.</entry>
</row>

<row>
<entry>void enableRandomMode(bool enable)</entry>
<entry>Switch Random Mode on or off.</entry>
</row>

<row>
<entry>void enableRepeatPlaylist(bool enable)</entry>
<entry>Switch Repeat Playlist on or off.</entry>
</row>

<row>
<entry>void enableRepeatTrack(bool enable)</entry>
<entry>Switch Repeat Track on or off.</entry>
</row>

<row>
<entry>void mediaDeviceMount()</entry>
<entry>Sets the command used for mounting media device.</entry>
</row>

<row>
<entry>void mediaDeviceUmount()</entry>
<entry>Sets the comment used for umounting media device.</entry>
</row>

<row>
<entry>void mute()</entry>
<entry>Toggle mute.</entry>
</row>

<row>
<entry>void next()</entry>
<entry>Equivalent to pressing "Next" button.</entry>
</row>

<row>
<entry>void pause()</entry>
<entry>Equivalent to pressing "Pause" button.</entry>
</row>

<row>
<entry>void play()</entry>
<entry>Equivalent to pressing "Play" button.</entry>
</row>

<row>
<entry>void playPause()</entry>
<entry>Toggle play/pause state (good for mm keyboard users) </entry>
</row>

<row>
<entry>void prev()</entry>
<entry>Equivalent to pressing "Prev" button.</entry>
</row>

<row>
<entry>void queueForTransfer( KURL url )</entry>
<entry>Queue file for transfer to Media Device.</entry>
</row>

<row>
<entry>void seek(int s)</entry>
<entry>Seek track to seconds position.</entry>
</row>

<row>
<entry>void seekRelative(int s)</entry>
<entry>Seek to a position relative to the current track position.</entry>
</row>

<row>
<entry>void setEqualizer(int, int, int, int, int, int, int, int, int, int, int)</entry>
<entry>Set the equalizer bands </entry>
</row>

<row>
<entry>void setEqualizerEnabled( bool active )</entry>
<entry>Toggle equalizer.</entry>
</row>

<row>
<entry>void setEqualizerPreset( QString name )</entry>
<entry>Set the equalizer preset </entry>
</row>

<row>
<entry>void setLyricsByPath( QString url, QString lyrics )</entry>
<entry>Set the lyrics of a track by it's path.</entry>
</row>

<row>
<entry>void setScore( int score )</entry>
<entry>Set the score of the currently playing track.</entry>
</row>

<row>
<entry>void setScoreByPath( QString url, int score )</entry>
<entry>Set the score of a track by it's path.</entry>
</row>

<row>
<entry>void setVolume(int volume)</entry>
<entry>Set volume in range 0-100%.</entry>
</row>

<row>
<entry>void showBrowser( QString browser )</entry>
<entry>Shows browsers in the playlist window</entry>
</row>

<row>
<entry>void showOSD()</entry>
<entry>Show the OSD display on the screen.</entry>
</row>

<row>
<entry>void stop()</entry>
<entry>Equivalent to pressing "Stop" button.</entry>
</row>

<row>
<entry>void transferDeviceFiles()</entry>
<entry>Transfer files to media device.</entry>
</row>

<row>
<entry>void volumeDown()</entry>
<entry>Decrease volume by a reasonable step.</entry>
</row>

<row>
<entry>void volumeUp()</entry>
<entry>Increase volume by a reasonable step.</entry>
</row>

</tbody>
</tgroup>
</informaltable>

</sect2>

<sect2 id="dcop-playlist">
<title>dcop amarok playlist</title>

<informaltable>
<tgroup cols="2">
<thead>

<row>
<entry>DCOP Call</entry>
<entry>Action</entry>
</row>
</thead>
<tbody>

<row>
<entry>int getActiveIndex()</entry>
<entry>Return the index of the currently active track. -1 if none.</entry>
</row>

<row>
<entry>int getTotalTrackCount()</entry>
<entry>Return number of tracks in playlist. 0 if none.</entry>
</row>

<row>
<entry>QString saveCurrentPlaylist()</entry>
<entry>Saves the current playlist to current.xml and returns its path.</entry>
</row>

<row>
<entry>void addMedia( KURL )</entry>
<entry>Add audio media specified by the url.</entry>
</row>

<row>
<entry>void addMediaList( KURL::List )</entry>
<entry>Add some audio media specified by the url.</entry>
</row>

<row>
<entry>void clearPlaylist()</entry>
<entry>Clears the playlist.</entry>
</row>

<row>
<entry>void playByIndex(int)</entry>
<entry>Starts playing the track at the specified index.</entry>
</row>

<row>
<entry>void playMedia( KURL )</entry>
<entry>Add audio media specified by the url.</entry>
</row>

<row>
<entry>void popupMessage( QString)</entry>
<entry>Shows a temporary popup message.</entry>
</row>

<row>
<entry>void removeCurrentTrack()</entry>
<entry>Removes the current-track item from the playlist.</entry>
</row>

<row>
<entry>void repopulate()</entry>
<entry>Repopulate the playlist with random tracks.</entry>
</row>

<row>
<entry>void saveM3u( QString path, bool relativePaths)</entry>
<entry>Saves the current playlist as m3u.</entry>
</row>

<row>
<entry>void setStopAfterCurrent( bool )</entry>
<entry>Enables/disables the "Stop After Current Track" feature.</entry>
</row>

<row>
<entry>void shortStatusMessage( QString)</entry>
<entry>Shows a temporary message on the statusbar.</entry>
</row>

<row>
<entry>void shufflePlaylist()</entry>
<entry>Shuffles the playlist.</entry>
</row>

<row>
<entry>void togglePlaylist()</entry>
<entry>Toggle the Playlist-window.</entry>
</row>

</tbody>
</tgroup>
</informaltable>

</sect2>

<sect2 id="dcop-playlistbrowser">
<title>dcop amarok playlistbrowser</title>

<informaltable>
<tgroup cols="2">
<thead>

<row>
<entry>DCOP Call</entry>
<entry>Action</entry>
</row>
</thead>
<tbody>

<row>
<entry>void addPodcast( QString )</entry>
<entry>Add a podcast entry to the playlist browser.</entry>
</row>

<row>
<entry>void scanPodcasts()</entry>
<entry>Scan all podcasts for updates.</entry>
</row>

<row>
<entry>void addPlaylist( QString )</entry>
<entry>Add a playlist to the playlist browser.</entry>
</row>

</tbody>
</tgroup>
</informaltable>

</sect2>

<sect2 id="dcop-script">
<title>dcop amarok script</title>


<informaltable>
<tgroup cols="2">
<thead>

<row>
<entry>DCOP Call</entry>
<entry>Action</entry>
</row>
</thead>
<tbody>

<row>
<entry>bool runScript( QString name)</entry>
<entry>Starts the script with the given name. Returns true on success.</entry>
</row>

<row>
<entry>bool stopScript( QString name)</entry>
<entry>Stops the script with the given name. Returns true on success.</entry>
</row>

<row>
<entry>QStringList listRunningScripts()</entry>
<entry>Returns a list of all currently running scripts.</entry>
</row>

<row>
<entry>void addCustomMenuItem(QString submenu, QString itemTitle )</entry>
<entry>Enables and sets custom menu item title.</entry>
</row>

<row>
<entry>void removeCustomMenuItem(QString submenu, QString itemTitle )</entry>
<entry>Removes the custom menu item.</entry>
</row>

<row>
<entry>QString readConfig( QString key)</entry>
<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>

<programlisting>
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
</programlisting>

</sect2>

<sect2 id="script-templates">
<title>Getting Started: The Templates</title>

<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>

<programlisting>
<cmdsynopsis><command>configure</command></cmdsynopsis>
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.
</programlisting>

<programlisting>
<cmdsynopsis><command>engineStateChange:</command><arg>empty|idle|paused|playing</arg></cmdsynopsis>
Signals a change in the engine's state.
</programlisting>

<programlisting>
<cmdsynopsis><command>trackChange</command></cmdsynopsis>
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.
</programlisting>

<programlisting>
<cmdsynopsis><command>volumeChange</command><arg>newVolume</arg></cmdsynopsis>
Signals a change of the master volume level. The volume is an integer with a
range of 0-100.
</programlisting>

<programlisting>
<cmdsynopsis><command>customMenuClicked:</command><arg>submenu itemTitle paths</arg></cmdsynopsis>
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 )'.
</programlisting>

</sect2>

<sect2 id="script-termination">
<title>Script Termination</title>

<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>

</sect2>

<sect2 id="script-packaging">
<title>Packaging</title>

<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>

<programlisting>tar -cf myscript.amarokscript.tar -p myscript</programlisting>

<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>

</sect2>

</sect1>


</chapter>