[PATCH 0/9] Teach xmms to handle "skip forward/backward 5 seconds" from prompt
Kristoffer Sederlof <[email protected]> Sat, 27 Aug 2005 23:29:24 +0300 (EEST)
| Newsgroups | gmane.comp.multimedia.xmms.devel |
|---|---|
| Message-ID | <[email protected]> |
Howdy!
First off:
A big thank you to all of the people who have been involved
in creating xmms, great work, all of you!
I have been enjoying xmms for many years now but there's always been
one thing that I've been lacking from xmms (well, not always, but
since I managed to key-bind xmms' basic functions ie. Prev / Play /
Pause / Stop / Next to "Alt_Gr + (z|x|c|v|b)") and that is the ability
to skip forward/backward in the current song via xmms' remote features
(ie "xmms -f" and it's friends...).
And being some what of a short-cut nutter and always having to active
the xmms window (in a multi virtual desktop environment) and then with
the _mouse_ having to skip forward/backward in the song started to got
on my tits ;-)
So, here are 9 patches to xmms-1.2.10 that, when applied will make
xmms be able to handle skipping forward/backwards in the current song
via the remove commands:
marvin[~/src/xmms] $ xmms --help
Usage: xmms [options] [files] ...
Options:
--------
-h, --help Display this text and exit.
-n, --session Select XMMS session (Default: 0)
-r, --rew Skip backwards in playlist
-p, --play Start playing current playlist
-u, --pause Pause current song
-s, --stop Stop current song
-t, --play-pause Pause if playing, play otherwise
-f, --fwd Skip forward in playlist
==> -F, --Fwd Skip forward 5 seconds in current song
==> -B, --Back Skip backwords 5 seconds in current song
-e, --enqueue Don't clear the playlist
-m, --show-main-window Show the main window.
-i, --sm-client-id Previous session ID
-v, --version Print version number and exit.
In other words, if you would be using Fvwm as your windows manager and
if you placed this into your "~/.fvwm2rc":
#################################################################
# [ Alt Gr ] XMMS shortcuts ;)
#################################################################
# To get "Alt Gr" working I had to put this line:
# "add Mod3 = ISO_Level3_Shift" to my "~/.Xmodmap"-file
#################################################################
Key z A 3 Exec xmms -r & # Rewind (previous)
Key x A 3 Exec xmms -p & # play
Key c A 3 Exec xmms -u & # pause
Key v A 3 Exec xmms -s & # stop
Key b A 3 Exec xmms -f & # forward (next)
Key a A 3 Exec xmms -B & # Backwards 5 sec track
Key s A 3 Exec xmms -F & # Forward 5 sec track
You would now be able to use the xmms gui's normal keyboard short-cuts
from anywhere when used with "Alt_Gr + (z|x|c|v|b)", PLUS if you would
want to skip say, 15 seconds into the song, you would just issue:
Alt_Gr + s # times three...
This makes xmms perfect for me, thanks once again for the great
software you've created!!!
[ Another change that could be handy is instead of the hardcoded 5
seconds the user would give skip time as the second argument, ie
"xmms --F 20" would skip skip 20 seconds right of the bat.
Who knows, if no body else does it, maybe I'll send a patch that
does just that in a while ;-]
Here follows all the patches in one bunch, I'll separately send the
same patches to this thread as well.
Please consider applying.
Signed-off-by: Kristoffer Sederlöf <[email protected]>
---
diff -Nru ./xmms-1.2.10/xmms/controlsocket.h.orig ./xmms-1.2.10/xmms/controlsocket.h
--- ./xmms-1.2.10/xmms/controlsocket.h.orig 2005-08-09 23:16:10.000000000 +0300
+++ ./xmms-1.2.10/xmms/controlsocket.h 2005-08-10 21:52:37.000000000 +0300
@@ -46,6 +46,7 @@
CMD_GET_EQ, CMD_GET_EQ_PREAMP, CMD_GET_EQ_BAND,
CMD_SET_EQ, CMD_SET_EQ_PREAMP, CMD_SET_EQ_BAND,
CMD_QUIT, CMD_PLAYLIST_INS_URL_STRING, CMD_PLAYLIST_INS, CMD_PLAY_PAUSE,
+ CMD_FWD5SEC, CMD_BACK5SEC
};
typedef struct
diff -Nru ./xmms-1.2.10/xmms/input.c.orig ./xmms-1.2.10/xmms/input.c
--- ./xmms-1.2.10/xmms/input.c.orig 2005-08-09 23:13:44.000000000 +0300
+++ ./xmms-1.2.10/xmms/input.c 2005-08-10 22:02:45.000000000 +0300
@@ -308,6 +308,24 @@
ip_data->playing = FALSE;
}
+void input_fwd5sec(void)
+{
+ if (ip_data->playing && get_current_input_plugin())
+ {
+ if (get_input_playing() && playlist_get_current_length() != -1)
+ input_seek(((((input_get_time() / 1000) + 5) < (playlist_get_current_length() / 1000)) ? ((input_get_time() / 1000) + 5) : ((playlist_get_current_length() / 1000) - 1)));
+ }
+}
+
+void input_back5sec(void)
+{
+ if (ip_data->playing && get_current_input_plugin())
+ {
+ if (get_input_playing() && playlist_get_current_length() != -1)
+ input_seek((((input_get_time() / 1000) - 5 >= 0) ? (input_get_time() / 1000) - 5 : 0));
+ }
+}
+
void input_pause(void)
{
if (get_input_playing() && get_current_input_plugin())
diff -Nru ./xmms-1.2.10/xmms/input.h.orig ./xmms-1.2.10/xmms/input.h
--- ./xmms-1.2.10/xmms/input.h.orig 2005-08-09 23:13:44.000000000 +0300
+++ ./xmms-1.2.10/xmms/input.h 2005-08-10 22:06:11.000000000 +0300
@@ -35,6 +35,8 @@
void input_play(char *filename);
void input_stop(void);
void input_pause(void);
+void input_fwd5sec(void);
+void input_back5sec(void);
int input_get_time(void);
void input_set_eq(int on, float preamp, float *bands);
void input_seek(int time);
diff -Nru ./xmms-1.2.10/xmms/main.c.orig ./xmms-1.2.10/xmms/main.c
--- ./xmms-1.2.10/xmms/main.c.orig 2005-08-09 23:13:54.000000000 +0300
+++ ./xmms-1.2.10/xmms/main.c 2005-08-27 17:43:32.000000000 +0300
@@ -3208,6 +3208,8 @@
{"play-pause", 0, NULL, 't'},
{"stop", 0, NULL, 's'},
{"fwd", 0, NULL, 'f'},
+ {"Fwd", 0, NULL, 'F'},
+ {"Back", 0, NULL, 'B'},
{"enqueue", 0, NULL, 'e'},
{"show-main-window", 0, NULL, 'm'},
{"version", 0, NULL, 'v'},
@@ -3244,6 +3246,12 @@
fprintf(stderr, "\n-f, --fwd ");
/* -f, --fwd switch */
fprintf(stderr, _("Skip forward in playlist"));
+ fprintf(stderr, "\n-F, --Fwd ");
+ /* -F, --Forward 5 seconds */
+ fprintf(stderr, _("Skip 5 seconds forward in current song"));
+ fprintf(stderr, "\n-B, --Back ");
+ /* -B, --Back 5 seconds */
+ fprintf(stderr, _("Skip 5 seconds backwords in current song"));
fprintf(stderr, "\n-e, --enqueue ");
/* -e, --enqueue switch */
fprintf(stderr, _("Don't clear the playlist"));
@@ -3264,6 +3272,7 @@
GList *filenames;
int session;
gboolean play, stop, pause, fwd, rew, play_pause;
+ gboolean fwd5sec, back5sec;
gboolean enqueue, mainwin, remote;
char *previous_session_id;
};
@@ -3275,7 +3284,7 @@
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:rpusfFBtmevi", long_options, NULL)) != -1)
{
switch (c)
{
@@ -3300,6 +3309,12 @@
case 'f':
opt->fwd = TRUE;
break;
+ case 'F':
+ opt->fwd5sec = TRUE;
+ break;
+ case 'B':
+ opt->back5sec = TRUE;
+ break;
case 't':
opt->play_pause = TRUE;
break;
@@ -3376,6 +3391,10 @@
xmms_remote_stop(opt->session);
if (opt->fwd)
xmms_remote_playlist_next(opt->session);
+ if (opt->fwd5sec)
+ xmms_remote_fwd5sec(opt->session);
+ if (opt->back5sec)
+ xmms_remote_back5sec(opt->session);
if (opt->play_pause)
xmms_remote_play_pause(opt->session);
if (opt->mainwin)
diff -Nru ./xmms-1.2.10/xmms/controlsocket.c.orig ./xmms-1.2.10/xmms/controlsocket.c
--- ./xmms-1.2.10/xmms/controlsocket.c.orig 2005-08-09 23:16:10.000000000 +0300
+++ ./xmms-1.2.10/xmms/controlsocket.c 2005-08-10 21:41:49.000000000 +0300
@@ -485,6 +485,12 @@
input_stop();
mainwin_clear_song_info();
break;
+ case CMD_FWD5SEC:
+ input_fwd5sec();
+ break;
+ case CMD_BACK5SEC:
+ input_back5sec();
+ break;
case CMD_PLAY_PAUSE:
if (get_input_playing())
input_pause();
diff -Nru ./xmms-1.2.10/libxmms/xmmsctrl.h.orig ./xmms-1.2.10/libxmms/xmmsctrl.h
--- ./xmms-1.2.10/libxmms/xmmsctrl.h.orig 2005-08-09 23:14:14.000000000 +0300
+++ ./xmms-1.2.10/libxmms/xmmsctrl.h 2005-08-10 21:10:59.000000000 +0300
@@ -34,6 +34,8 @@
void xmms_remote_play(gint session);
void xmms_remote_pause(gint session);
void xmms_remote_stop(gint session);
+void xmms_remote_fwd5sec(gint session);
+void xmms_remote_back5sec(gint session);
gboolean xmms_remote_is_playing(gint session);
gboolean xmms_remote_is_paused(gint session);
gint xmms_remote_get_playlist_pos(gint session);
diff -Nru ./xmms-1.2.10/libxmms/xmmsctrl.c.orig ./xmms-1.2.10/libxmms/xmmsctrl.c
--- ./xmms-1.2.10/libxmms/xmmsctrl.c.orig 2005-08-09 23:14:14.000000000 +0300
+++ ./xmms-1.2.10/libxmms/xmmsctrl.c 2005-08-10 21:15:57.000000000 +0300
@@ -377,6 +377,16 @@
remote_cmd(session, CMD_STOP);
}
+void xmms_remote_fwd5sec(gint session)
+{
+ remote_cmd(session, CMD_FWD5SEC);
+}
+
+void xmms_remote_back5sec(gint session)
+{
+ remote_cmd(session, CMD_BACK5SEC);
+}
+
void xmms_remote_play_pause(gint session)
{
remote_cmd(session, CMD_PLAY_PAUSE);
diff -Nru ./xmms-1.2.10/AUTHORS.orig ./xmms-1.2.10/AUTHORS
--- ./xmms-1.2.10/AUTHORS.orig 2005-08-09 23:06:07.000000000 +0300
+++ ./xmms-1.2.10/AUTHORS 2005-08-10 21:17:13.000000000 +0300
@@ -32,6 +32,7 @@
Josip Rodin
Pablo Saratxaga (i18n)
Carl van Schaik (pro logic plugin)
+ Kristoffer Sederlöf
Jörg Schuler
Charles Sielski (irman plugin)
Espen Skoglund
diff -Nru ./xmms-1.2.10/README.orig ./xmms-1.2.10/README
--- ./xmms-1.2.10/README.orig 2004-01-17 02:41:21.000000000 +0200
+++ ./xmms-1.2.10/README 2005-08-27 17:42:14.000000000 +0300
@@ -1116,6 +1116,8 @@
-s, --stop Stop current song
-t, --play-pause Pause if playing, play otherwise
-f, --fwd Skip forward in playlist
+-F, --Fwd Skip 5 seconds forward in current song
+-B, --Back Skip 5 seconds backwords in current song
-e, --enqueue Don't clear the playlist
-m, --show-main-window Show the main window
-v, --version Print version number and exit.
@@ -1224,11 +1226,42 @@
things can be binded to a key. I use AfterStep and the useless window keys
for this. Here is an example from my .steprc:
-Key Meta_R A N Exec "xmms" xmms -r
-Key Menu A N Exec "xmms" xmms -f
+ Key Meta_R A N Exec "xmms" xmms -r
+ Key Menu A N Exec "xmms" xmms -f
-If you want all your mp3's in one playlist an easy way is:
-locate .mp3 > /path/to/playlistname
+If you are using Fvwm as your window manager the following lines might
+be of interest (place in ~/.fvwm2rc":
+
+ # To get "Alt Gr" working I had to put this line:
+ # "add Mod3 = ISO_Level3_Shift" to my "~/.Xmodmap"-file
+ Key z A 3 Exec xmms -r & # Rewind (previous)
+ Key x A 3 Exec xmms -p & # play
+ Key c A 3 Exec xmms -u & # pause
+ Key v A 3 Exec xmms -s & # stop
+ Key b A 3 Exec xmms -f & # forward (next)
+
+ Key a A 3 Exec xmms -B & # Backwards 5 sec track
+ Key s A 3 Exec xmms -F & # Forward 5 sec track
+
+With the help of the commands above you have now made it possible to
+use xmms normal keyboard short-cuts from anywhere, without making xmms
+the active window.
+
+Ie. if you would like to skip to the next song while surfin or doing
+what ever you would just press:
+
+ "Alt_Gr + b"
+
+And if you for some reason don't like the beginning of that song, you
+would just issue:
+
+ "Alt_Gr + s"...
+
+As many time as you like (skips 5 seconds forward every time), pritty
+handy.
+
+If you want all your mp3's in one playlist an easy way is: locate .mp3
+> /path/to/playlistname
(considering you have a fairly recent updatedb, don't blame us if locate don't
find the file you downloaded 3 minutes ago)
_______________________________________________
xmms-devel mailing list
[email protected]
http://lists.xmms.org/mailman/listinfo/xmms-devel