Jiaom | 3 May 2011 12:53
Picon
Picon

Feature Request (play random Song / follow playback in view)

Hi everyone,

I recently discovered this great Music Player, however I'm missing two  
small Details. Having used foobar2000 before, I'd love to have a command  
that plays a random Song from the current view (would be great if usable  
via cmus-remote, too). In conjunction to that, it'd be great if there were  
a "Cursor follows Playback" equivalent. Simply an option to append  
"win-sel-cur" to every track change would be awesome. If something like  
this is already possible, I'd be glad if you give me a small hint in how  
to get it working.

Greetings

Jiaom

------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd

Johannes Weißl | 3 May 2011 14:36

Re: Feature Request (play random Song / follow playback in view)

Hello Jiaom,

On Tue, May 03, 2011 at 12:53:28PM +0200, Jiaom wrote:
> I recently discovered this great Music Player, however I'm missing two  
> small Details.

Thanks for your suggestions and great you like cmus!

> Having used foobar2000 before, I'd love to have a command  that plays
> a random Song from the current view (would be great if usable  via
> cmus-remote, too).

There is the "tqueue" command to queue a random song from the library.
As far as I know, there is no way to get the current view via
cmus-remote, so there is no possibility to script this behaviour.

Are there any objections to output the current view via
`cmus-remote -Q`? Then a script would be possible!

> In conjunction to that, it'd be great if there were  a "Cursor follows
> Playback" equivalent. Simply an option to append  "win-sel-cur" to
> every track change would be awesome. If something like  this is
> already possible, I'd be glad if you give me a small hint in how  to
> get it working.

This has been requested multiple times in the past. I wrote a small
shell script which accomplishes that:
http://cmus.sourceforge.net/wiki/doku.php?id=cmus_follow_playback

Can you check if it works? You have to set it as status_display_program:
(Continue reading)

a.l.e | 3 May 2011 14:44
Picon

Re: Feature Request (play random Song / follow playback in view)

hi

> > Having used foobar2000 before, I'd love to have a command that plays
>> a random Song from the current view (would be great if usable  via
>> cmus-remote, too).
>

the one thing i've been wondering several time: is there a way to 
randomize the current queue (or pick a random song from the queue)?

my use case is:
- i add several albums (or songs sorted by authour) to the queue
- and then i won't to listen to all those songs in a random order

ciao
a.l.e

------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd

Johannes Weißl | 3 May 2011 15:08

Re: Feature Request (play random Song / follow playback in view)

On Tue, May 03, 2011 at 02:44:48PM +0200, a.l.e wrote:
> the one thing i've been wondering several time: is there a way to 
> randomize the current queue (or pick a random song from the queue)?
> 
> my use case is:
> - i add several albums (or songs sorted by authour) to the queue
> - and then i won't to listen to all those songs in a random order

Hmm, I don't think randomizing the queue is possible at the moment. But
why not use the playlist instead? If you want to use the queue, I wrote
a script that pushes tracks/albums to the queue in a random order:
http://cmus.sourceforge.net/wiki/doku.php?id=cmus_queue_randomly

You can bind it to a key:
:bind -f common ^E run cmus_queue_randomly

Does this solve your problem?

Johannes
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
Johannes Weißl | 3 May 2011 15:54

Re: Feature Request (play random Song / follow playback in view)

On Tue, May 03, 2011 at 02:36:31PM +0200, Johannes Weißl wrote:
> As far as I know, there is no way to get the current view via
> cmus-remote, so there is no possibility to script this behaviour.

I was wrong, I wrote a (bit hacky) script that does select the next
track in the current view (view 1-3):
http://cmus.sourceforge.net/wiki/doku.php?id=cmus_play_random

Is this what you meant?

Johannes
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
Johannes Weißl | 3 May 2011 22:37

Re: Feature Request (play random Song / follow playback in view)

On Tue, May 03, 2011 at 02:36:31PM +0200, Johannes Weißl wrote:
> This has been requested multiple times in the past. I wrote a small
> shell script which accomplishes that:
> http://cmus.sourceforge.net/wiki/doku.php?id=cmus_follow_playback

Just wanted to clarify that I uploaded all scripts in this thread while
writing the mails (had them / or similar scripts locally). Otherwise it
looks like I would suggest that people didn't RTFM... sorry for that!

Johannes
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
Johannes Weißl | 4 May 2011 03:10

[PATCH 2/3] expand '~' for options which receive filenames

options:
dsp.ao.wav_dir
status_display_program

e.g.:
:set status_display_program=~/bin/foo
---
 ao.c           |    2 +-
 command_mode.c |   58 --------------------------------------------------------
 misc.c         |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 misc.h         |    3 ++
 options.c      |    2 +-
 5 files changed, 63 insertions(+), 60 deletions(-)

diff --git a/ao.c b/ao.c
index ac45df2..668eb32 100644
--- a/ao.c
+++ b/ao.c
 <at>  <at>  -189,7 +189,7  <at>  <at>  static int op_ao_get_option(int key, char **val)
 	case 3:
 		if (wav_dir == NULL)
 			wav_dir = xstrdup(home_dir);
-		*val = xstrdup(wav_dir);
+		*val = expand_filename(wav_dir);
 		break;
 	default:
 		return -OP_ERROR_NOT_OPTION;
diff --git a/command_mode.c b/command_mode.c
index 3fcceb2..687fbee 100644
--- a/command_mode.c
(Continue reading)

Johannes Weißl | 4 May 2011 03:10

[PATCH 1/3] tab-complete commands which take program paths

commands are :run and :shell
---
 command_mode.c |   19 +++++++++++++-
 load_dir.h     |   13 ++++++++++
 misc.c         |    8 ++++++
 misc.h         |    1 +
 tabexp_file.c  |   73 +++++++++++++++++++++++++++++++++++++++++++++++--------
 tabexp_file.h  |    2 +
 6 files changed, 103 insertions(+), 13 deletions(-)

diff --git a/command_mode.c b/command_mode.c
index 99d8f4e..3fcceb2 100644
--- a/command_mode.c
+++ b/command_mode.c
 <at>  <at>  -1968,6 +1968,11  <at>  <at>  static int filter_directories(const char *name, const struct stat *s)
 	return S_ISDIR(s->st_mode);
 }

+static int filter_executable_files(const char *name, const struct stat *s)
+{
+	return S_ISREG(s->st_mode) && (s->st_mode & 0111);
+}
+
 static int filter_any(const char *name, const struct stat *s)
 {
 	return 1;
 <at>  <at>  -2030,6 +2035,16  <at>  <at>  static void expand_add(const char *str)
 	}
 }

(Continue reading)

Johannes Weißl | 4 May 2011 03:10

[PATCH 3/3] tab-complete status_display_program option

---
 command_mode.c |   41 ++++++++++++++++++++++++++++-------------
 options.c      |   20 ++++++++++++--------
 options.h      |    8 +++++++-
 output.c       |    4 ++--
 4 files changed, 49 insertions(+), 24 deletions(-)

diff --git a/command_mode.c b/command_mode.c
index 687fbee..2e0d645 100644
--- a/command_mode.c
+++ b/command_mode.c
 <at>  <at>  -1987,6 +1987,17  <at>  <at>  static void expand_program_paths(const char *str)
 		expand_env_path(str, filter_executable_files);
 }

+static void expand_program_paths_option(const char *str, const char *opt)
+{
+	expand_program_paths(str);
+
+	if (tabexp.head && opt) {
+		snprintf(expbuf, sizeof(expbuf), "%s=%s", opt, tabexp.head);
+		free(tabexp.head);
+		tabexp.head = xstrdup(expbuf);
+	}
+}
+
 static void expand_load_save(const char *str)
 {
 	int flag = parse_flags(&str, "lp");
 <at>  <at>  -2257,29 +2268,33  <at>  <at>  static void expand_options(const char *str)
(Continue reading)

Johannes Weißl | 4 May 2011 04:49

[PATCH] fixup! make get_home_dir private

---
 misc.c |    2 +-
 misc.h |    1 -
 2 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/misc.c b/misc.c
index 1d5621e..e18f099 100644
--- a/misc.c
+++ b/misc.c
 <at>  <at>  -219,7 +219,7  <at>  <at>  int replaygain_decode(unsigned int field, int *gain)
 	return name_code;
 }

-char *get_home_dir(const char *username)
+static char *get_home_dir(const char *username)
 {
 	struct passwd *passwd;

diff --git a/misc.h b/misc.h
index 120f431..aa4f9ae 100644
--- a/misc.h
+++ b/misc.h
 <at>  <at>  -43,6 +43,5  <at>  <at>  const char *unescape(const char *str);
 int replaygain_decode(unsigned int field, int *gain);

 char *expand_filename(const char *name);
-char *get_home_dir(const char *username);

 #endif
--

-- 
(Continue reading)


Gmane