/* $Id$ * $URL$ * * XMMS-Plugin for LCD4Linux * Copyright (C) 2003 Markus Keil * * This file is part of LCD4Linux. * * LCD4Linux is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * LCD4Linux is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * exported functions: * * int plugin_init_xmms (void) * adds parser for /tmp/xmms-info * */ /* * The Argument 'arg1' must be one of these Things (without brackets): * * 'Title' - The title of the current song * 'Status' - The status of XMMS (playing, pause, ...) * 'Tunes in playlist' - How many entries are in the playlist * 'Currently playing' - which playlist-entry is playing * 'uSecPosition' - The position of the title in seconds (usefull for bargraphs ;-) ) * 'Position' - The position of the title in mm:ss * 'uSecTime' - The length of the current title in seconds * 'Time' - The length of the current title in mm:ss * 'Current bitrate' - The current bitrate in bit * 'Samping Frequency' - The current samplingfreqency in Hz * 'Channels' - The current number of audiochannels * 'File' - The full path of the current file * * These arguments are case-sensitive */ #include "config.h" #include #include #include #include "hash.h" #include "debug.h" #include "plugin.h" static HASH xmms; static int parse_xmms_info(void) { int age; FILE *xmms_stream; char zeile[200]; /* reread every 100msec only */ age = hash_age(&xmms, NULL); if (age >= 0 && age <= 200) return 0; /* Open Filestream for '/tmp/xmms-info' */ xmms_stream = fopen("/tmp/xmms-info", "r"); /* Check for File */ if (!xmms_stream) { error("Error: Cannot open XMMS-Info Stream! Is XMMS started?"); return -1; } /* Read Lines from the Stream */ while (fgets(zeile, sizeof(zeile), xmms_stream)) { char *c, *key, *val; c = strchr(zeile, ':'); if (c == NULL) continue; key = zeile; val = c + 1; /* strip leading blanks from key */ while (isspace(*key)) *key++ = '\0'; /* strip trailing blanks from key */ do *c = '\0'; while (isspace(*--c)); /* strip leading blanks from value */ while (isspace(*val)) *val++ = '\0'; /* strip trailing blanks from value */ for (c = val; *c != '\0'; c++); while (isspace(*--c)) *c = '\0'; hash_put(&xmms, key, val); } fclose(xmms_stream); return 0; } static void my_xmms(RESULT * result, RESULT * arg1) { char *key, *val; if (parse_xmms_info() < 0) { SetResult(&result, R_STRING, ""); return; } key = R2S(arg1); val = hash_get(&xmms, key, NULL); if (val == NULL) val = ""; SetResult(&result, R_STRING, val); } int plugin_init_xmms(void) { hash_create(&xmms); /* register xmms info */ AddFunction("xmms", 1, my_xmms); return 0; } void plugin_exit_xmms(void) { hash_destroy(&xmms); } an>/+413 2004-06-26[lcd4linux @ 2004-06-26 09:27:20 by reinelt]reinelt71-1842/+2274 2004-06-26[lcd4linux @ 2004-06-26 06:12:14 by reinelt]reinelt7-111/+562 2004-06-24[lcd4linux @ 2004-06-24 20:18:08 by nicowallmeier]nicowallmeier1-2/+5 2004-06-20[lcd4linux @ 2004-06-20 10:12:27 by reinelt]reinelt1-0/+110 2004-06-20[lcd4linux @ 2004-06-20 10:09:52 by reinelt]reinelt51-377/+569 2004-06-19[lcd4linux @ 2004-06-19 08:20:19 by reinelt]reinelt2-7/+17 2004-06-17[lcd4linux @ 2004-06-17 10:58:57 by reinelt]reinelt3-76/+84 2004-06-17[lcd4linux @ 2004-06-17 06:23:39 by reinelt]reinelt19-403/+633 2004-06-13[lcd4linux @ 2004-06-13 01:12:52 by reinelt]reinelt3-18/+34 2004-06-09[lcd4linux @ 2004-06-09 06:40:29 by reinelt]reinelt3-11/+35 2004-06-08[lcd4linux @ 2004-06-08 21:46:38 by reinelt]reinelt5-31/+131 2004-06-08[lcd4linux @ 2004-06-08 12:35:24 by reinelt]reinelt6-882/+474 2004-06-07[lcd4linux @ 2004-06-07 07:02:13 by reinelt]reinelt1-0/+33 2004-06-07[lcd4linux @ 2004-06-07 06:56:55 by reinelt]reinelt5-7/+149 2004-06-06[lcd4linux @ 2004-06-06 06:51:59 by reinelt]reinelt16-52/+135 2004-06-05[lcd4linux @ 2004-06-05 14:56:48 by reinelt]reinelt3-24/+37 2004-06-05[lcd4linux @ 2004-06-05 06:41:39 by reinelt]reinelt11-42/+87 2004-06-05[lcd4linux @ 2004-06-05 06:13:11 by reinelt]reinelt9-69/+327 2004-06-02[lcd4linux @ 2004-06-02 10:09:22 by reinelt]reinelt4-180/+183 2004-06-02[lcd4linux @ 2004-06-02 09:41:19 by reinelt]reinelt18-114/+211 2004-06-02[lcd4linux @ 2004-06-02 05:56:25 by reinelt]reinelt1-2/+6 2004-06-02[lcd4linux @ 2004-06-02 05:35:55 by reinelt]reinelt1-0/+20 2004-06-02[lcd4linux @ 2004-06-02 05:27:59 by reinelt]reinelt26-0/+2405 2004-06-02[lcd4linux @ 2004-06-02 05:14:16 by reinelt]reinelt2-17/+31 2004-06-01[lcd4linux @ 2004-06-01 06:45:28 by reinelt]reinelt18-71/+241 2004-06-01[lcd4linux @ 2004-06-01 06:04:25 by reinelt]reinelt2-25/+25 2004-05-31[lcd4linux @ 2004-05-31 21:23:16 by reinelt]reinelt1-37/+49 2004-05-31[lcd4linux @ 2004-05-31 21:05:13 by reinelt]reinelt5-77/+111 2004-05-31[lcd4linux @ 2004-05-31 16:39:05 by reinelt]reinelt11-180/+535 2004-05-31[lcd4linux @ 2004-05-31 06:27:34 by reinelt]reinelt1-0/+40 2004-05-31[lcd4linux @ 2004-05-31 06:24:42 by reinelt]reinelt2-7/+29 2004-05-31[lcd4linux @ 2004-05-31 05:38:02 by reinelt]reinelt8-42/+94 2004-05-31[lcd4linux @ 2004-05-31 01:31:01 by andy-b]andy-b1-10/+12 2004-05-30[lcd4linux @ 2004-05-30 08:25:50 by reinelt]reinelt2-30/+92 2004-05-29[lcd4linux @ 2004-05-29 23:30:20 by reinelt]reinelt1-1/+9 2004-05-29[lcd4linux @ 2004-05-29 15:53:28 by reinelt]reinelt3-9/+25 2004-05-29[lcd4linux @ 2004-05-29 01:07:56 by reinelt]reinelt2-21/+25 2004-05-29[lcd4linux @ 2004-05-29 00:27:14 by reinelt]reinelt8-11/+214 2004-05-28[lcd4linux @ 2004-05-28 14:38:10 by reinelt]reinelt2-1/+41