Mercurial > audlegacy
annotate audtool/audtool.c @ 1832:1c7e25c619e9 trunk
[svn] - fix that goddamn skinlist bug
author | nenolod |
---|---|
date | Thu, 05 Oct 2006 07:57:40 -0700 |
parents | 705d4c089fce |
children | 111f30d09ef2 |
rev | line source |
---|---|
1200 | 1 /* Audtool -- Audacious scripting tool |
2 * Copyright (c) 2005-2006 George Averill, William Pitcock | |
3 * | |
4 * This program is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; either version 2 of the License, or | |
7 * (at your option) any later version. | |
8 * | |
9 * This program is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU General Public License | |
15 * along with this program; if not, write to the Free Software | |
1459 | 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
1200 | 17 */ |
18 | |
19 #include <stdlib.h> | |
20 #include <glib.h> | |
1225 | 21 #include "libaudacious/beepctrl.h" |
1200 | 22 #include "audtool.h" |
23 | |
24 struct commandhandler handlers[] = { | |
1316 | 25 {"<sep>", NULL, "Vital information"}, |
1200 | 26 {"current-song", get_current_song, "returns current song title"}, |
27 {"current-song-filename", get_current_song_filename, "returns current song filename"}, | |
28 {"current-song-length", get_current_song_length, "returns current song length"}, | |
29 {"current-song-length-seconds", get_current_song_length_seconds, "returns current song length in seconds"}, | |
30 {"current-song-length-frames", get_current_song_length_frames, "returns current song length in frames"}, | |
31 {"current-song-output-length", get_current_song_output_length, "returns current song output length"}, | |
32 {"current-song-output-length-seconds", get_current_song_output_length_seconds, "returns current song output length in seconds"}, | |
33 {"current-song-output-length-frames", get_current_song_output_length_frames, "returns current song output length in frames"}, | |
34 {"current-song-bitrate", get_current_song_bitrate, "returns current song bitrate in bits per second"}, | |
35 {"current-song-bitrate-kbps", get_current_song_bitrate_kbps, "returns current song bitrate in kilobits per second"}, | |
36 {"current-song-frequency", get_current_song_frequency, "returns current song frequency in hertz"}, | |
37 {"current-song-frequency-khz", get_current_song_frequency_khz, "returns current song frequency in kilohertz"}, | |
38 {"current-song-channels", get_current_song_channels, "returns current song channels"}, | |
1316 | 39 {"<sep>", NULL, "Playlist manipulation"}, |
1200 | 40 {"playlist-advance", playlist_advance, "go to the next song in the playlist"}, |
41 {"playlist-reverse", playlist_reverse, "go to the previous song in the playlist"}, | |
42 {"playlist-addurl", playlist_add_url_string, "adds a url to the playlist"}, | |
1365 | 43 {"playlist-delete", playlist_delete, "deletes a song from the playlist"}, |
1200 | 44 {"playlist-length", playlist_length, "returns the total length of the playlist"}, |
45 {"playlist-song", playlist_song, "returns the title of a song in the playlist"}, | |
46 {"playlist-song-filename", playlist_song_filename, "returns the filename of a song in the playlist"}, | |
47 {"playlist-song-length", playlist_song_length, "returns the length of a song in the playlist"}, | |
48 {"playlist-song-length-seconds", playlist_song_length_seconds, "returns the length of a song in the playlist in seconds"}, | |
49 {"playlist-song-length-frames", playlist_song_length_frames, "returns the length of a song in the playlist in frames"}, | |
50 {"playlist-display", playlist_display, "returns the entire playlist"}, | |
51 {"playlist-position", playlist_position, "returns the position in the playlist"}, | |
52 {"playlist-jump", playlist_jump, "jumps to a position in the playlist"}, | |
53 {"playlist-clear", playlist_clear, "clears the playlist"}, | |
54 {"playlist-repeat-status", playlist_repeat_status, "returns the status of playlist repeat"}, | |
55 {"playlist-repeat-toggle", playlist_repeat_toggle, "toggles playlist repeat"}, | |
56 {"playlist-shuffle-status", playlist_shuffle_status, "returns the status of playlist shuffle"}, | |
57 {"playlist-shuffle-toggle", playlist_shuffle_toggle, "toggles playlist shuffle"}, | |
1316 | 58 {"<sep>", NULL, "Playqueue manipulation"}, |
1200 | 59 {"playqueue-add", playqueue_add, "adds a song to the playqueue"}, |
60 {"playqueue-remove", playqueue_remove, "removes a song from the playqueue"}, | |
61 {"playqueue-is-queued", playqueue_is_queued, "returns OK if a song is queued"}, | |
62 {"playqueue-get-position", playqueue_get_position, "returns the queue position of a song in the playlist"}, | |
63 {"playqueue-get-qposition", playqueue_get_qposition, "returns the playlist position of a song in the queue"}, | |
64 {"playqueue-length", playqueue_length, "returns the length of the playqueue"}, | |
65 {"playqueue-display", playqueue_display, "returns a list of currently-queued songs"}, | |
66 {"playqueue-clear", playqueue_clear, "clears the playqueue"}, | |
1316 | 67 {"<sep>", NULL, "Playback manipulation"}, |
1200 | 68 {"playback-play", playback_play, "starts/unpauses song playback"}, |
69 {"playback-pause", playback_pause, "(un)pauses song playback"}, | |
70 {"playback-playpause", playback_playpause, "plays/(un)pauses song playback"}, | |
71 {"playback-stop", playback_stop, "stops song playback"}, | |
72 {"playback-playing", playback_playing, "returns OK if audacious is playing"}, | |
73 {"playback-paused", playback_paused, "returns OK if audacious is paused"}, | |
74 {"playback-stopped", playback_stopped, "returns OK if audacious is stopped"}, | |
75 {"playback-status", playback_status, "returns the playback status"}, | |
1316 | 76 {"<sep>", NULL, "Volume control"}, |
1200 | 77 {"get-volume", get_volume, "returns the current volume level in percent"}, |
78 {"set-volume", set_volume, "sets the current volume level in percent"}, | |
1319
3783e06f951b
[svn] - s/Miscillaneous/Miscellaneous/ in audtool.c
nhjm449
parents:
1316
diff
changeset
|
79 {"<sep>", NULL, "Miscellaneous"}, |
1200 | 80 {"preferences", show_preferences_window, "shows/hides the preferences window"}, |
81 {"jumptofile", show_jtf_window, "shows the jump to file window"}, | |
82 {"shutdown", shutdown_audacious_server, "shuts down audacious"}, | |
1316 | 83 {"<sep>", NULL, "Help system"}, |
1200 | 84 {"list-handlers", get_handlers_list, "shows handlers list"}, |
85 {"help", get_handlers_list, "shows handlers list"}, | |
86 {NULL, NULL, NULL} | |
87 }; | |
88 | |
89 gint main(gint argc, gchar **argv) | |
90 { | |
91 gint i; | |
1440
acdc12679d1a
[svn] - allow environment variable AUDTOOL_REMOTE_URI to influence where the client library accesses the audacious session
nenolod
parents:
1365
diff
changeset
|
92 gchar *remote_uri; |
1200 | 93 |
94 if (argc < 2) | |
95 { | |
96 g_print("%s: usage: %s <command>\n", argv[0], argv[0]); | |
97 g_print("%s: use `%s help' to get a listing of available commands.\n", | |
98 argv[0], argv[0]); | |
99 exit(0); | |
100 } | |
101 | |
1440
acdc12679d1a
[svn] - allow environment variable AUDTOOL_REMOTE_URI to influence where the client library accesses the audacious session
nenolod
parents:
1365
diff
changeset
|
102 remote_uri = getenv("AUDTOOL_REMOTE_URI"); |
acdc12679d1a
[svn] - allow environment variable AUDTOOL_REMOTE_URI to influence where the client library accesses the audacious session
nenolod
parents:
1365
diff
changeset
|
103 audacious_set_session_uri(remote_uri); |
acdc12679d1a
[svn] - allow environment variable AUDTOOL_REMOTE_URI to influence where the client library accesses the audacious session
nenolod
parents:
1365
diff
changeset
|
104 |
1203
a09393433f83
[svn] - OMKize Makefile (examples not installed yet)
nenolod
parents:
1200
diff
changeset
|
105 if (!xmms_remote_is_running(0) && g_strcasecmp("help", argv[1]) |
a09393433f83
[svn] - OMKize Makefile (examples not installed yet)
nenolod
parents:
1200
diff
changeset
|
106 && g_strcasecmp("list-handlers", argv[1])) |
1200 | 107 { |
108 g_print("%s: audacious server is not running!\n", argv[0]); | |
109 exit(0); | |
110 } | |
111 | |
112 for (i = 0; handlers[i].name != NULL; i++) | |
113 { | |
1203
a09393433f83
[svn] - OMKize Makefile (examples not installed yet)
nenolod
parents:
1200
diff
changeset
|
114 if ((!g_strcasecmp(handlers[i].name, argv[1]) || |
a09393433f83
[svn] - OMKize Makefile (examples not installed yet)
nenolod
parents:
1200
diff
changeset
|
115 !g_strcasecmp(g_strconcat("--", handlers[i].name, NULL), argv[1])) |
a09393433f83
[svn] - OMKize Makefile (examples not installed yet)
nenolod
parents:
1200
diff
changeset
|
116 && g_strcasecmp("<sep>", handlers[i].name)) |
1200 | 117 { |
118 handlers[i].handler(0, argc, argv); | |
119 exit(0); | |
120 } | |
121 } | |
122 | |
123 g_print("%s: invalid command '%s'\n", argv[0], argv[1]); | |
124 g_print("%s: use `%s help' to get a listing of available commands.\n", argv[0], argv[0]); | |
125 | |
126 return 0; | |
127 } | |
128 | |
129 /*** MOVE TO HANDLERS.C ***/ | |
130 | |
131 void get_current_song(gint session, gint argc, gchar **argv) | |
132 { | |
133 gint playpos = xmms_remote_get_playlist_pos(session); | |
134 gchar *song = xmms_remote_get_playlist_title(session, playpos); | |
135 | |
136 if (!song) | |
137 { | |
138 g_print("No song playing.\n"); | |
139 return; | |
140 } | |
141 | |
142 g_print("%s\n", song); | |
143 } | |
144 | |
145 void get_current_song_filename(gint session, gint argc, gchar **argv) | |
146 { | |
147 gint playpos = xmms_remote_get_playlist_pos(session); | |
148 | |
149 g_print("%s\n", xmms_remote_get_playlist_file(session, playpos)); | |
150 } | |
151 | |
152 void get_current_song_output_length(gint session, gint argc, gchar **argv) | |
153 { | |
154 gint frames = xmms_remote_get_output_time(session); | |
155 gint length = frames / 1000; | |
156 | |
157 g_print("%d:%.2d\n", length / 60, length % 60); | |
158 } | |
159 | |
160 void get_current_song_output_length_seconds(gint session, gint argc, gchar **argv) | |
161 { | |
162 gint frames = xmms_remote_get_output_time(session); | |
163 gint length = frames / 1000; | |
164 | |
165 g_print("%d\n", length); | |
166 } | |
167 | |
168 void get_current_song_output_length_frames(gint session, gint argc, gchar **argv) | |
169 { | |
170 gint frames = xmms_remote_get_output_time(session); | |
171 | |
172 g_print("%d\n", frames); | |
173 } | |
174 | |
175 void get_current_song_length(gint session, gint argc, gchar **argv) | |
176 { | |
177 gint playpos = xmms_remote_get_playlist_pos(session); | |
178 gint frames = xmms_remote_get_playlist_time(session, playpos); | |
179 gint length = frames / 1000; | |
180 | |
181 g_print("%d:%.2d\n", length / 60, length % 60); | |
182 } | |
183 | |
184 void get_current_song_length_seconds(gint session, gint argc, gchar **argv) | |
185 { | |
186 gint playpos = xmms_remote_get_playlist_pos(session); | |
187 gint frames = xmms_remote_get_playlist_time(session, playpos); | |
188 gint length = frames / 1000; | |
189 | |
190 g_print("%d\n", length); | |
191 } | |
192 | |
193 void get_current_song_length_frames(gint session, gint argc, gchar **argv) | |
194 { | |
195 gint playpos = xmms_remote_get_playlist_pos(session); | |
196 gint frames = xmms_remote_get_playlist_time(session, playpos); | |
197 | |
198 g_print("%d\n", frames); | |
199 } | |
200 | |
201 void get_current_song_bitrate(gint session, gint argc, gchar **argv) | |
202 { | |
203 gint rate, freq, nch; | |
204 | |
205 xmms_remote_get_info(session, &rate, &freq, &nch); | |
206 | |
207 g_print("%d\n", rate); | |
208 } | |
209 | |
210 void get_current_song_bitrate_kbps(gint session, gint argc, gchar **argv) | |
211 { | |
212 gint rate, freq, nch; | |
213 | |
214 xmms_remote_get_info(session, &rate, &freq, &nch); | |
215 | |
216 g_print("%d\n", rate / 1000); | |
217 } | |
218 | |
219 void get_current_song_frequency(gint session, gint argc, gchar **argv) | |
220 { | |
221 gint rate, freq, nch; | |
222 | |
223 xmms_remote_get_info(session, &rate, &freq, &nch); | |
224 | |
225 g_print("%d\n", freq); | |
226 } | |
227 | |
228 void get_current_song_frequency_khz(gint session, gint argc, gchar **argv) | |
229 { | |
230 gint rate, freq, nch; | |
231 | |
232 xmms_remote_get_info(session, &rate, &freq, &nch); | |
233 | |
234 g_print("%0.1f\n", (gfloat) freq / 1000); | |
235 } | |
236 | |
237 void get_current_song_channels(gint session, gint argc, gchar **argv) | |
238 { | |
239 gint rate, freq, nch; | |
240 | |
241 xmms_remote_get_info(session, &rate, &freq, &nch); | |
242 | |
243 g_print("%d\n", nch); | |
244 } | |
245 | |
246 void playlist_reverse(gint session, gint argc, gchar **argv) | |
247 { | |
248 xmms_remote_playlist_prev(session); | |
249 } | |
250 | |
251 void playlist_advance(gint session, gint argc, gchar **argv) | |
252 { | |
253 xmms_remote_playlist_next(session); | |
254 } | |
255 | |
256 void playback_play(gint session, gint argc, gchar **argv) | |
257 { | |
258 xmms_remote_play(session); | |
259 } | |
260 | |
261 void playback_pause(gint session, gint argc, gchar **argv) | |
262 { | |
263 xmms_remote_pause(session); | |
264 } | |
265 | |
266 void playback_playpause(gint session, gint argc, gchar **argv) | |
267 { | |
268 if (xmms_remote_is_playing(session)) | |
269 { | |
270 xmms_remote_pause(session); | |
271 } | |
272 else | |
273 { | |
274 xmms_remote_play(session); | |
275 } | |
276 } | |
277 | |
278 void playback_stop(gint session, gint argc, gchar **argv) | |
279 { | |
280 xmms_remote_stop(session); | |
281 } | |
282 | |
283 void playback_playing(gint session, gint argc, gchar **argv) | |
284 { | |
285 if (!xmms_remote_is_paused(session)) | |
286 { | |
287 exit(!xmms_remote_is_playing(session)); | |
288 } | |
289 else | |
290 { | |
291 exit(1); | |
292 } | |
293 } | |
294 | |
295 void playback_paused(gint session, gint argc, gchar **argv) | |
296 { | |
297 exit(!xmms_remote_is_paused(session)); | |
298 } | |
299 | |
300 void playback_stopped(gint session, gint argc, gchar **argv) | |
301 { | |
302 if (!xmms_remote_is_playing(session) && !xmms_remote_is_paused(session)) | |
303 { | |
304 exit(0); | |
305 } | |
306 else | |
307 { | |
308 exit(1); | |
309 } | |
310 } | |
311 | |
312 void playback_status(gint session, gint argc, gchar **argv) | |
313 { | |
314 if (xmms_remote_is_paused(session)) | |
315 { | |
316 g_print("paused\n"); | |
317 return; | |
318 } | |
319 else if (xmms_remote_is_playing(session)) | |
320 { | |
321 g_print("playing\n"); | |
322 return; | |
323 } | |
324 else | |
325 { | |
326 g_print("stopped\n"); | |
327 return; | |
328 } | |
329 } | |
330 | |
331 void playlist_add_url_string(gint session, gint argc, gchar **argv) | |
332 { | |
333 if (argc < 3) | |
334 { | |
335 g_print("%s: invalid parameters for playlist-addurl.\n", argv[0]); | |
336 g_print("%s: syntax: %s playlist-addurl <url>\n", argv[0], argv[0]); | |
337 return; | |
338 } | |
339 | |
340 xmms_remote_playlist_add_url_string(session, argv[2]); | |
341 } | |
342 | |
1365 | 343 void playlist_delete(gint session, gint argc, gchar **argv) |
344 { | |
345 if (argc < 3) | |
346 { | |
347 g_print("%s: invalid parameters for playlist-delete.\n", argv[0]); | |
348 g_print("%s: syntax: %s playlist-delete <position>\n", argv[0], argv[0]); | |
349 return; | |
350 } | |
351 | |
352 gint playpos = atoi(argv[2]); | |
353 | |
354 if (playpos < 1 || playpos > xmms_remote_get_playlist_length(session)) | |
355 { | |
356 g_print("%s: invalid playlist position %d\n", argv[0], playpos); | |
357 return; | |
358 } | |
359 | |
360 xmms_remote_playlist_delete(session, playpos - 1); | |
361 } | |
362 | |
1200 | 363 void playlist_length(gint session, gint argc, gchar **argv) |
364 { | |
365 gint i; | |
366 | |
367 i = xmms_remote_get_playlist_length(session); | |
368 | |
369 g_print("%d\n", i); | |
370 } | |
371 | |
372 void playlist_song(gint session, gint argc, gchar **argv) | |
373 { | |
374 if (argc < 3) | |
375 { | |
376 g_print("%s: invalid parameters for playlist-song-title.\n", argv[0]); | |
377 g_print("%s: syntax: %s playlist-song-title <position>\n", argv[0], argv[0]); | |
378 return; | |
379 } | |
380 | |
381 gint playpos = atoi(argv[2]); | |
382 | |
383 if (playpos < 1 || playpos > xmms_remote_get_playlist_length(session)) | |
384 { | |
385 g_print("%s: invalid playlist position %d\n", argv[0], playpos); | |
386 return; | |
387 } | |
388 | |
389 gchar *song = xmms_remote_get_playlist_title(session, playpos - 1); | |
390 | |
391 g_print("%s\n", song); | |
392 } | |
393 | |
394 | |
395 void playlist_song_length(gint session, gint argc, gchar **argv) | |
396 { | |
397 if (argc < 3) | |
398 { | |
399 g_print("%s: invalid parameters for playlist-song-length.\n", argv[0]); | |
400 g_print("%s: syntax: %s playlist-song-length <position>\n", argv[0], argv[0]); | |
401 return; | |
402 } | |
403 | |
404 gint playpos = atoi(argv[2]); | |
405 | |
406 if (playpos < 1 || playpos > xmms_remote_get_playlist_length(session)) | |
407 { | |
408 g_print("%s: invalid playlist position %d\n", argv[0], playpos); | |
409 return; | |
410 } | |
411 | |
412 gint frames = xmms_remote_get_playlist_time(session, playpos - 1); | |
413 gint length = frames / 1000; | |
414 | |
415 g_print("%d:%.2d\n", length / 60, length % 60); | |
416 } | |
417 | |
418 void playlist_song_length_seconds(gint session, gint argc, gchar **argv) | |
419 { | |
420 if (argc < 3) | |
421 { | |
422 g_print("%s: invalid parameters for playlist-song-length-seconds.\n", argv[0]); | |
423 g_print("%s: syntax: %s playlist-song-length-seconds <position>\n", argv[0], argv[0]); | |
424 return; | |
425 } | |
426 | |
427 gint playpos = atoi(argv[2]); | |
428 | |
429 if (playpos < 1 || playpos > xmms_remote_get_playlist_length(session)) | |
430 { | |
431 g_print("%s: invalid playlist position %d\n", argv[0], playpos); | |
432 return; | |
433 } | |
434 | |
435 gint frames = xmms_remote_get_playlist_time(session, playpos - 1); | |
436 gint length = frames / 1000; | |
437 | |
438 g_print("%d\n", length); | |
439 } | |
440 | |
441 void playlist_song_length_frames(gint session, gint argc, gchar **argv) | |
442 { | |
443 if (argc < 3) | |
444 { | |
445 g_print("%s: invalid parameters for playlist-song-length-frames.\n", argv[0]); | |
446 g_print("%s: syntax: %s playlist-song-length-frames <position>\n", argv[0], argv[0]); | |
447 return; | |
448 } | |
449 | |
450 gint playpos = atoi(argv[2]); | |
451 | |
452 if (playpos < 1 || playpos > xmms_remote_get_playlist_length(session)) | |
453 { | |
454 g_print("%s: invalid playlist position %d\n", argv[0], playpos); | |
455 return; | |
456 } | |
457 | |
458 gint frames = xmms_remote_get_playlist_time(session, playpos - 1); | |
459 | |
460 g_print("%d\n", frames); | |
461 } | |
462 | |
463 void playlist_display(gint session, gint argc, gchar **argv) | |
464 { | |
465 gint i, ii, frames, length, total; | |
466 gchar *songname; | |
467 | |
468 i = xmms_remote_get_playlist_length(session); | |
469 | |
470 g_print("%d tracks.\n", i); | |
471 | |
472 total = 0; | |
473 | |
474 for (ii = 0; ii < i; ii++) | |
475 { | |
476 songname = xmms_remote_get_playlist_title(session, ii); | |
477 frames = xmms_remote_get_playlist_time(session, ii); | |
478 length = frames / 1000; | |
479 total += length; | |
480 | |
481 g_print("%4d | %-60s | %d:%.2d\n", | |
482 ii + 1, songname, length / 60, length % 60); | |
483 } | |
484 | |
485 g_print("Total length: %d:%.2d\n", total / 60, total % 60); | |
486 } | |
487 | |
488 void playlist_position(gint session, gint argc, gchar **argv) | |
489 { | |
490 gint i; | |
491 | |
492 i = xmms_remote_get_playlist_pos(session); | |
493 | |
494 g_print("%d\n", i + 1); | |
495 } | |
496 | |
497 void playlist_song_filename(gint session, gint argc, gchar **argv) | |
498 { | |
499 gint i; | |
500 | |
501 if (argc < 3) | |
502 { | |
503 g_print("%s: invalid parameters for playlist-filename.\n", argv[0]); | |
504 g_print("%s: syntax: %s playlist-filename <position>\n", argv[0], argv[0]); | |
505 return; | |
506 } | |
507 | |
508 i = atoi(argv[2]); | |
509 | |
510 if (i < 1 || i > xmms_remote_get_playlist_length(session)) | |
511 { | |
512 g_print("%s: invalid playlist position %d\n", argv[0], i); | |
513 return; | |
514 } | |
515 | |
516 g_print("%s\n", xmms_remote_get_playlist_file(session, i - 1)); | |
517 } | |
518 | |
519 void playlist_jump(gint session, gint argc, gchar **argv) | |
520 { | |
521 gint i; | |
522 | |
523 if (argc < 3) | |
524 { | |
525 g_print("%s: invalid parameters for playlist-jump.\n", argv[0]); | |
526 g_print("%s: syntax: %s playlist-jump <position>\n", argv[0], argv[0]); | |
527 return; | |
528 } | |
529 | |
530 i = atoi(argv[2]); | |
531 | |
532 if (i < 1 || i > xmms_remote_get_playlist_length(session)) | |
533 { | |
534 g_print("%s: invalid playlist position %d\n", argv[0], i); | |
535 return; | |
536 } | |
537 | |
538 xmms_remote_set_playlist_pos(session, i - 1); | |
539 } | |
540 | |
541 void playlist_clear(gint session, gint argc, gchar **argv) | |
542 { | |
543 xmms_remote_playlist_clear(session); | |
544 } | |
545 | |
546 void playlist_repeat_status(gint session, gint argc, gchar **argv) | |
547 { | |
548 if (xmms_remote_is_repeat(session)) | |
549 { | |
550 g_print("on\n"); | |
551 return; | |
552 } | |
553 else | |
554 { | |
555 g_print("off\n"); | |
556 return; | |
557 } | |
558 } | |
559 | |
560 void playlist_repeat_toggle(gint session, gint argc, gchar **argv) | |
561 { | |
562 xmms_remote_toggle_repeat(session); | |
563 } | |
564 | |
565 void playlist_shuffle_status(gint session, gint argc, gchar **argv) | |
566 { | |
567 if (xmms_remote_is_shuffle(session)) | |
568 { | |
569 g_print("on\n"); | |
570 return; | |
571 } | |
572 else | |
573 { | |
574 g_print("off\n"); | |
575 return; | |
576 } | |
577 } | |
578 | |
579 void playlist_shuffle_toggle(gint session, gint argc, gchar **argv) | |
580 { | |
581 xmms_remote_toggle_shuffle(session); | |
582 } | |
583 | |
584 void playqueue_add(gint session, gint argc, gchar **argv) | |
585 { | |
1204
76e6b66fb859
[svn] - compiles warningless inside the audacious buildsystem now
nenolod
parents:
1203
diff
changeset
|
586 gint i; |
1200 | 587 |
588 if (argc < 3) | |
589 { | |
590 g_print("%s: invalid parameters for playqueue-add.\n", argv[0]); | |
591 g_print("%s: syntax: %s playqueue-add <position>\n", argv[0], argv[0]); | |
592 return; | |
593 } | |
594 | |
595 i = atoi(argv[2]); | |
596 | |
597 if (i < 1 || i > xmms_remote_get_playlist_length(session)) | |
598 { | |
599 g_print("%s: invalid playlist position %d\n", argv[0], i); | |
600 return; | |
601 } | |
602 | |
603 if (!(xmms_remote_playqueue_is_queued(session, i - 1))) | |
604 xmms_remote_playqueue_add(session, i - 1); | |
605 } | |
606 | |
607 void playqueue_remove(gint session, gint argc, gchar **argv) | |
608 { | |
1204
76e6b66fb859
[svn] - compiles warningless inside the audacious buildsystem now
nenolod
parents:
1203
diff
changeset
|
609 gint i; |
1200 | 610 |
611 if (argc < 3) | |
612 { | |
613 g_print("%s: invalid parameters for playqueue-remove.\n", argv[0]); | |
614 g_print("%s: syntax: %s playqueue-remove <position>\n", argv[0], argv[0]); | |
615 return; | |
616 } | |
617 | |
618 i = atoi(argv[2]); | |
619 | |
620 if (i < 1 || i > xmms_remote_get_playlist_length(session)) | |
621 { | |
622 g_print("%s: invalid playlist position %d\n", argv[0], i); | |
623 return; | |
624 } | |
625 | |
626 if (xmms_remote_playqueue_is_queued(session, i - 1)) | |
627 xmms_remote_playqueue_remove(session, i - 1); | |
628 } | |
629 | |
630 void playqueue_is_queued(gint session, gint argc, gchar **argv) | |
631 { | |
632 gint i; | |
633 | |
634 if (argc < 3) | |
635 { | |
636 g_print("%s: invalid parameters for playqueue-is-queued.\n", argv[0]); | |
637 g_print("%s: syntax: %s playqueue-is-queued <position>\n", argv[0], argv[0]); | |
638 return; | |
639 } | |
640 | |
641 i = atoi(argv[2]); | |
642 | |
643 if (i < 1 || i > xmms_remote_get_playlist_length(session)) | |
644 { | |
645 g_print("%s: invalid playlist position %d\n", argv[0], i); | |
646 return; | |
647 } | |
648 | |
649 exit(!(xmms_remote_playqueue_is_queued(session, i - 1))); | |
650 } | |
651 | |
652 void playqueue_get_position(gint session, gint argc, gchar **argv) | |
653 { | |
654 gint i, pos; | |
655 | |
656 if (argc < 3) | |
657 { | |
658 g_print("%s: invalid parameters for playqueue-get-position.\n", argv[0]); | |
659 g_print("%s: syntax: %s playqueue-get-position <position>\n", argv[0], argv[0]); | |
660 return; | |
661 } | |
662 | |
663 i = atoi(argv[2]); | |
664 | |
665 if (i < 1 || i > xmms_remote_get_playlist_length(session)) | |
666 { | |
667 g_print("%s: invalid playlist position %d\n", argv[0], i); | |
668 return; | |
669 } | |
670 | |
671 pos = xmms_remote_get_playqueue_position(session, i - 1) + 1; | |
672 | |
673 if (pos < 1) | |
674 return; | |
675 | |
676 g_print("%d\n", pos); | |
677 } | |
678 | |
679 void playqueue_get_qposition(gint session, gint argc, gchar **argv) | |
680 { | |
681 gint i, pos; | |
682 | |
683 if (argc < 3) | |
684 { | |
685 g_print("%s: invalid parameters for playqueue-get-qposition.\n", argv[0]); | |
686 g_print("%s: syntax: %s playqueue-get-qposition <position>\n", argv[0], argv[0]); | |
687 return; | |
688 } | |
689 | |
690 i = atoi(argv[2]); | |
691 | |
692 if (i < 1 || i > xmms_remote_get_playqueue_length(session)) | |
693 { | |
694 g_print("%s: invalid playlist position %d\n", argv[0], i); | |
695 return; | |
696 } | |
697 | |
698 pos = xmms_remote_get_playqueue_queue_position(session, i - 1) + 1; | |
699 | |
700 if (pos < 1) | |
701 return; | |
702 | |
703 g_print("%d\n", pos); | |
704 } | |
705 | |
706 void playqueue_display(gint session, gint argc, gchar **argv) | |
707 { | |
708 gint i, ii, position, frames, length, total; | |
709 gchar *songname; | |
710 | |
711 i = xmms_remote_get_playqueue_length(session); | |
712 | |
713 g_print("%d queued tracks.\n", i); | |
714 | |
715 total = 0; | |
716 | |
717 for (ii = 0; ii < i; ii++) | |
718 { | |
719 position = xmms_remote_get_playqueue_queue_position(session, ii); | |
720 songname = xmms_remote_get_playlist_title(session, position); | |
721 frames = xmms_remote_get_playlist_time(session, position); | |
722 length = frames / 1000; | |
723 total += length; | |
724 | |
725 g_print("%4d | %4d | %-60s | %d:%.2d\n", | |
726 ii + 1, position + 1, songname, length / 60, length % 60); | |
727 } | |
728 | |
729 g_print("Total length: %d:%.2d\n", total / 60, total % 60); | |
730 } | |
731 | |
732 void playqueue_length(gint session, gint argc, gchar **argv) | |
733 { | |
734 gint i; | |
735 | |
736 i = xmms_remote_get_playqueue_length(session); | |
737 | |
738 g_print("%d\n", i); | |
739 } | |
740 | |
741 void playqueue_clear(gint session, gint argc, gchar **argv) | |
742 { | |
743 xmms_remote_playqueue_clear(session); | |
744 } | |
745 | |
746 void get_volume(gint session, gint argc, gchar **argv) | |
747 { | |
748 gint i; | |
749 | |
750 i = xmms_remote_get_main_volume(session); | |
751 | |
752 g_print("%d\n", i); | |
753 } | |
754 | |
755 void set_volume(gint session, gint argc, gchar **argv) | |
756 { | |
757 gint i, current_volume; | |
758 | |
759 if (argc < 3) | |
760 { | |
761 g_print("%s: invalid parameters for set-volume.\n", argv[0]); | |
762 g_print("%s: syntax: %s set-volume <level>\n", argv[0], argv[0]); | |
763 return; | |
764 } | |
765 | |
766 current_volume = xmms_remote_get_main_volume(session); | |
767 switch (argv[2][0]) | |
768 { | |
769 case '+': | |
770 case '-': | |
771 i = current_volume + atoi(argv[2]); | |
772 break; | |
773 default: | |
774 i = atoi(argv[2]); | |
775 break; | |
776 } | |
777 | |
778 xmms_remote_set_main_volume(session, i); | |
779 } | |
780 | |
781 void show_preferences_window(gint session, gint argc, gchar **argv) | |
782 { | |
783 xmms_remote_show_prefs_box(session); | |
784 } | |
785 | |
786 void show_jtf_window(gint session, gint argc, gchar **argv) | |
787 { | |
788 xmms_remote_show_jtf_box(session); | |
789 } | |
790 | |
791 void shutdown_audacious_server(gint session, gint argc, gchar **argv) | |
792 { | |
793 xmms_remote_quit(session); | |
794 } | |
795 | |
796 void get_handlers_list(gint session, gint argc, gchar **argv) | |
797 { | |
798 gint i; | |
799 | |
800 for (i = 0; handlers[i].name != NULL; i++) | |
801 { | |
1203
a09393433f83
[svn] - OMKize Makefile (examples not installed yet)
nenolod
parents:
1200
diff
changeset
|
802 if (!g_strcasecmp("<sep>", handlers[i].name)) |
1316 | 803 g_print("%s%s:\n", i == 0 ? "" : "\n", handlers[i].desc); |
1200 | 804 else |
805 g_print(" %-34s - %s\n", handlers[i].name, handlers[i].desc); | |
806 } | |
807 | |
808 g_print("\nHandlers may be prefixed with `--' (GNU-style long-options) or not, your choice.\n"); | |
809 g_print("Report bugs to http://bugs.audacious-media-player.org.\n"); | |
810 } |