Patch for XMMS - reload current skin via cmdline

Peter Ganzhorn <[email protected]> Sat, 10 Sep 2005 14:23:14 +0200
Newsgroups gmane.comp.multimedia.xmms.devel
Message-ID <[email protected]>
Hi,

I just created a small patch for XMMS which allows you to reload the 
current skin from the commandline; it is attached to this mail.

The changes include:
* The new feature itself ;)
* Commandline options "-q" and "--reload_skin"
* Information about the feature in the info text available via "xmms -h"

This patch simply makes the already existing function reload_skin() 
available on the commandline such as the play/stop/pause functions.

Some of you guys may wonder if this patch is necessary or even sensible 
at all - in fact, it is.
I am using fluxbox as WM and created a set of scripts which allows to 
easily change the look and feel of the complete desktop - including the 
wallpaper, terminals or other eye-candy applications.
So you got a bunch of configuration files, pictures and skins which are 
linked to special destinations and then get reloaded.

With my patch for XMMS one can easily integrate different XMMS skins for 
different desktop "presets" :)

I would be glad to see this being merged into XMMS 1.2.11.

regards,
Peter Ganzhorn

_______________________________________________
xmms-devel mailing list
[email protected]
http://lists.xmms.org/mailman/listinfo/xmms-devel
cmdline_reload_skin.diff (text/x-patch, 4.1 KB)
--- xmms-1.2.10/xmms/main.c	2004-02-23 21:31:43.000000000 +0100
+++ xmms-1.2.10.S/xmms/main.c	2005-09-10 13:35:42.000000000 +0200
@@ -3211,8 +3211,9 @@
 	{"enqueue", 0, NULL, 'e'},
 	{"show-main-window", 0, NULL, 'm'},
 	{"version", 0, NULL, 'v'},
 	{"sm-client-id", 1, NULL, 'i'},
+	{"reload_skin", 0, NULL, 'q'},
 	{0, 0, 0, 0}
 };
 
 void display_usage(void)
@@ -3252,8 +3253,11 @@
 	fprintf(stderr, _("Show the main window."));
 	fprintf(stderr, "\n-i, --sm-client-id	");
 	/* -i, --sm-client-id switch */
 	fprintf(stderr, _("Previous session ID"));
+	fprintf(stderr, "\n-q, --reload_skin		");
+	/* -q, --reload_skin switch */
+	fprintf(stderr, _("Reload current skin."));
 	fprintf(stderr, "\n-v, --version		");
 	/* -v, --version switch */
 	fprintf(stderr, _("Print version number and exit."));
 	fprintf(stderr, "\n\n");
@@ -3262,9 +3266,9 @@
 
 struct cmdlineopt {
 	GList *filenames;
 	int session;
-	gboolean play, stop, pause, fwd, rew, play_pause;
+	gboolean play, stop, pause, fwd, rew, play_pause, reload_skin;
 	gboolean enqueue, mainwin, remote;
 	char *previous_session_id;
 };
 
@@ -3274,9 +3278,9 @@
 	char *filename;
 
 	memset(opt, 0, sizeof(struct cmdlineopt));
 	opt->session = -1;
-	while ((c = getopt_long(argc, argv, "hn:rpusfemvt", long_options, NULL)) != -1)
+	while ((c = getopt_long(argc, argv, "hn:rpusfemvtq", long_options, NULL)) != -1)
 	{
 		switch (c)
 		{
 			case 'h':
@@ -3315,8 +3319,11 @@
 				break;
 			case 'i':
 				opt->previous_session_id = g_strdup(optarg);
 				break;
+			case 'q':
+				opt->reload_skin = TRUE;
+				break;
 		}
 	}
 	for (i = optind; i < argc; i++)
 	{
@@ -3379,8 +3386,10 @@
 	if (opt->play_pause)
 		xmms_remote_play_pause(opt->session);
 	if (opt->mainwin)
 		xmms_remote_main_win_toggle(opt->session, TRUE);
+	if (opt->reload_skin)
+		xmms_remote_reload_skin(opt->session);
 }
 
 void segfault_handler(int sig)
 {
--- xmms-1.2.10/libxmms/xmmsctrl.h	2003-06-11 20:44:17.000000000 +0200
+++ xmms-1.2.10.S/libxmms/xmmsctrl.h	2005-09-10 13:13:02.000000000 +0200
@@ -48,8 +48,9 @@
 void xmms_remote_set_volume(gint session, gint vl, gint vr);
 void xmms_remote_set_main_volume(gint session, gint v);
 void xmms_remote_set_balance(gint session, gint b);
 gchar *xmms_remote_get_skin(gint session);
+void xmms_remote_reload_skin(gint session);
 void xmms_remote_set_skin(gint session, gchar * skinfile);
 gchar *xmms_remote_get_playlist_file(gint session, gint pos);
 gchar *xmms_remote_get_playlist_title(gint session, gint pos);
 gint xmms_remote_get_playlist_time(gint session, gint pos);
--- xmms-1.2.10/xmms/controlsocket.c	2004-02-23 21:31:43.000000000 +0100
+++ xmms-1.2.10.S/xmms/controlsocket.c	2005-09-10 13:34:18.000000000 +0200
@@ -514,8 +514,11 @@
 				break;
 			case CMD_SET_SKIN:
 				load_skin(data);
 				break;
+			case CMD_RELOAD_SKIN:
+				reload_skin();
+				break;
 			case CMD_PL_WIN_TOGGLE:
 				tbool = *((gboolean *) data);
 				playlistwin_show(!!tbool);
 				break;
--- xmms-1.2.10/xmms/controlsocket.h	2003-06-11 20:44:17.000000000 +0200
+++ xmms-1.2.10.S/xmms/controlsocket.h	2005-09-10 12:15:04.000000000 +0200
@@ -33,9 +33,9 @@
 	CMD_GET_VERSION, CMD_PLAYLIST_ADD, CMD_PLAY, CMD_PAUSE, CMD_STOP,
 	CMD_IS_PLAYING, CMD_IS_PAUSED, CMD_GET_PLAYLIST_POS,
 	CMD_SET_PLAYLIST_POS, CMD_GET_PLAYLIST_LENGTH, CMD_PLAYLIST_CLEAR,
 	CMD_GET_OUTPUT_TIME, CMD_JUMP_TO_TIME, CMD_GET_VOLUME,
-	CMD_SET_VOLUME, CMD_GET_SKIN, CMD_SET_SKIN, CMD_GET_PLAYLIST_FILE,
+	CMD_SET_VOLUME, CMD_GET_SKIN, CMD_SET_SKIN, CMD_RELOAD_SKIN, CMD_GET_PLAYLIST_FILE,
 	CMD_GET_PLAYLIST_TITLE, CMD_GET_PLAYLIST_TIME, CMD_GET_INFO,
 	CMD_GET_EQ_DATA, CMD_SET_EQ_DATA, CMD_PL_WIN_TOGGLE,
 	CMD_EQ_WIN_TOGGLE, CMD_SHOW_PREFS_BOX, CMD_TOGGLE_AOT,
 	CMD_SHOW_ABOUT_BOX, CMD_EJECT, CMD_PLAYLIST_PREV, CMD_PLAYLIST_NEXT,
--- xmms-1.2.10/libxmms/xmmsctrl.c	2004-02-23 21:31:42.000000000 +0100
+++ xmms-1.2.10.S/libxmms/xmmsctrl.c	2005-09-10 13:14:07.000000000 +0200
@@ -536,8 +536,13 @@
 {
 	remote_send_string(session, CMD_SET_SKIN, skinfile);
 }
 
+void xmms_remote_reload_skin(gint session)
+{
+	remote_cmd(session, CMD_RELOAD_SKIN);
+}
+
 gchar *xmms_remote_get_playlist_file(gint session, gint pos)
 {
 	return remote_get_string_pos(session, CMD_GET_PLAYLIST_FILE, pos);
 }