Discussion:
Plugin for osd-lyrics
Alejandro Pulver
2012-03-02 21:06:57 UTC
Permalink
Hello,

I've been recently using cmus, and I like it.

There is a program to display lyrics called osd-lyrics which uses
plugins to integrate with audio players. I want to write one for cmus,
but it requires a way to get currently playing song's information.

It seems to use polling, instead of receiving a notification (but I
could cache the information from status-display-program in the plugin).
The problem is that the information isn't enough: notification of seeks
is required to synchronize the highlighted part of the lyrics with the
song. So there are at least two solutions:

1. Add an option for notifying of seeks in status-display-program.
2. Add a command (so it can be called from cmus-remote) to print the
currently playing song's path, title, artist, album, duration and
position, in an easy to parse way like "path = %s\ntitle = %s\n...".

I would prefer the second one, as a pipe to cmus-remote has to be kept
open anyways (to control cmus from osd-lyrics) and it doesn't require
manual user configuration.

What do you think about this?

Thanks and Regards,
Ale
Jason Woofenden
2012-03-02 22:48:08 UTC
Permalink
Post by Alejandro Pulver
Hello,
I've been recently using cmus, and I like it.
Yay :)
Post by Alejandro Pulver
There is a program to display lyrics called osd-lyrics which uses
plugins to integrate with audio players. I want to write one for cmus,
but it requires a way to get currently playing song's information.
Fun.

I think this command will give you all the info you need:

cmus-remote -Q


This gives the position in the song, and duration in seconds. I
hope that's accurate enough.

Also, as much as I love the efficiency of status_display_program,
those less comfortable with shell scripting are sometimes put off
by it, especially when it comes to wanting a second program hooked
in, and then they need to create a shell script that calls both.


When you get something working let us know!

Also please feel welcome to post code on our wiki:

http://cmus.sourceforge.net/wiki/doku.php


Take care,

- Jason
Alejandro Pulver
2012-03-03 05:37:02 UTC
Permalink
Post by Jason Woofenden
cmus-remote -Q
This gives the position in the song, and duration in seconds. I
hope that's accurate enough.
Thank you very much, I missed it. The program uses milliseconds
resolution, but seems to work fine anyways (in fact, the MOC plugin is
in the same situation).
Post by Jason Woofenden
Also, as much as I love the efficiency of status_display_program,
those less comfortable with shell scripting are sometimes put off
by it, especially when it comes to wanting a second program hooked
in, and then they need to create a shell script that calls both.
I've seen the example multiplexer in the wiki. What do you think of this
(note: untested)?

#!/bin/sh
cd ~/.cmus-status && \
for p in *; do test -x "$p" && ./"$p" "$@" &; done

So users just symlink or copy their scripts/programs to ~/.cmus-status,
and it should work.
Post by Jason Woofenden
When you get something working let us know!
I got it working, but I still have to read how to generate a diff with
git ("git add file.c; git diff" doesn't; strange when coming from a
CVS/SVN background). And I may also see if keeping the same cmus-remote
process running lowers the 7% CPU usage (now they are launched about
twice per second).
Post by Jason Woofenden
http://cmus.sourceforge.net/wiki/doku.php
Take care,
- Jason
You too.

I'll send the patches tomorrow.

Ale

P.S.: sorry for the duplicate, this one is sent to the list
Futuro
2012-03-03 05:57:16 UTC
Permalink
Try `git diff --cached`.

In git, when you `add` things, they go into the Index, which means you
then need to `commit` them to the history (I believe it's called
Tree). This is probably one of the most confusing things for people
coming from CVS/SVN, but it clarifies /a lot/ once explained. If you
have non-added changes in your working tree, `git status` will make
this really obvious.

I hope that helps, though I can find a link to a guide for git if
you're coming from the SVN world in a little bit otherwise.

- -F
Post by Alejandro Pulver
On 2012-03-02 06:06PM, Alejandro Pulver wrote: I think this
cmus-remote -Q
This gives the position in the song, and duration in seconds. I
hope that's accurate enough.
Thank you very much, I missed it. The program uses milliseconds
resolution, but seems to work fine anyways (in fact, the MOC plugin
is in the same situation).
Also, as much as I love the efficiency of
status_display_program, those less comfortable with shell
scripting are sometimes put off by it, especially when it comes
to wanting a second program hooked in, and then they need to
create a shell script that calls both.
I've seen the example multiplexer in the wiki. What do you think of
this (note: untested)?
#!/bin/sh cd ~/.cmus-status && \ for p in *; do test -x "$p" &&
So users just symlink or copy their scripts/programs to
~/.cmus-status, and it should work.
When you get something working let us know!
I got it working, but I still have to read how to generate a diff
with git ("git add file.c; git diff" doesn't; strange when coming
from a CVS/SVN background). And I may also see if keeping the same
cmus-remote process running lowers the 7% CPU usage (now they are
launched about twice per second).
http://cmus.sourceforge.net/wiki/doku.php
Take care,
- Jason
You too.
I'll send the patches tomorrow.
Ale
P.S.: sorry for the duplicate, this one is sent to the list
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Post by Alejandro Pulver
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
Alejandro Pulver
2012-03-03 21:28:42 UTC
Permalink
Post by Alejandro Pulver
Post by Jason Woofenden
cmus-remote -Q
This gives the position in the song, and duration in seconds. I
hope that's accurate enough.
Thank you very much, I missed it. The program uses milliseconds
resolution, but seems to work fine anyways (in fact, the MOC plugin
is in the same situation).
Yeah, I thought it might be good enough. You might add 500 ms as
the integer number of seconds is probably rounded down.
You're right, it is rounded down and it works better by adding 500ms.
Looks like it'd work. I don't have that installed, since I only run
one status display program. I'd be more inclined to try your lyrics
thing if I didn't have to meddle with my status_display_program.
Though, I guess it'd be pretty easy to call yours from mine.
Post by Alejandro Pulver
Post by Jason Woofenden
When you get something working let us know!
I got it working, but I still have to read how to generate a diff
with git ("git add file.c; git diff" doesn't; strange when coming
from a CVS/SVN background). And I may also see if keeping the same
cmus-remote process running lowers the 7% CPU usage (now they are
launched about twice per second).
To send patches to the mailing list, you'll want to make your
commit(s) (git add and git commit) then send the commits to the
mailing list.
Our beloved maintainer prefers that we send patches is with `git
[sendemail]
smtpserver = smtp.gmail.com
smtpssl = true
chainreplyto = false
suppress-cc = all
suppresscc = all
Then use `git log --decorate --oneline --all --graph` or some such
to figure out the name/etc of the commit just before your first
one. This may be "origin/master", if not replace "origin/master" in
Note the `--dry-run` this makes it so won't actually send the
e-mails, but will pretend to, and you can make sure it's sending
the right e-mails. It should send a summary e-mail, which you can
edit, and then one e-mail per commit. If you're sending just one
commit, remove the `--compose` flag.
Once you're confident it'll send the right e-mails, run it again
without `--dry-run` and this time put your message for the list in
the first e-mail.
I'm looking forward to seeing your patches, and seeing what they
do.
- Jason
There has been a misunderstanding: the patches are for osd-lyrics to
obtain information from cmus-remote periodically. So there is no need to
patch cmus nor use status-display-program.

I appreciate the git configuration and instructions, and will take it
into account when writing something for cmus. For the attached diff I
tried --cached as Futuro kindly suggested, but ended up using:

$ git add -N src/ol_player_cmus.[ch]
$ git diff --diff-filter=AM

The patch can be applied to the osd-lyrics source code at:
https://github.com/osdlyrics
Though it probably applies to the latest source tarball as well. After
running just select "cmus" from its menu, and start playing something in
cmus; it will fetch lyrics and display them.

Please note that the lyrics database is somewhat limited, and different
versions of songs may have slightly different timings.

Best Regards,
Ale
Gregory Petrosyan
2012-03-04 06:49:07 UTC
Permalink
Post by Alejandro Pulver
There has been a misunderstanding: the patches are for osd-lyrics to
obtain information from cmus-remote periodically. So there is no
need to patch cmus nor use status-display-program.
I appreciate the git configuration and instructions, and will take
it into account when writing something for cmus. For the attached
diff I tried --cached as Futuro kindly suggested, but ended up
$ git add -N src/ol_player_cmus.[ch]
$ git diff --diff-filter=AM
https://github.com/osdlyrics
Though it probably applies to the latest source tarball as well.
After running just select "cmus" from its menu, and start playing
something in cmus; it will fetch lyrics and display them.
If you want, you can try sending a pull request for your code to osdlyrics
repository.

Basically, all you need for this is to create a new branch
(git checkout -b cmus-integration), and commit your changes
(git commit -a -m"Add cmus support").

Then, you can try using GitHub's pull request feature
(http://help.github.com/send-pull-requests/), or send the patch directly to
the osdlyrics' maintainer (using 'git send-email' or 'git format-patch').

Gregory

Loading...