You are not logged in.
Hi,
I always liked the way one could search a huge xmms playlist for a song, sonata + mpd has a similar option, but it is really slow. using dmenu for displaying a mpd playlist like shown here http://mpd.wikia.com/wiki/Hack:Mpc-dmenu and applying a filter to it is fast, but kinda unusable when displayed the horizontal way.
So I wrote a patch for dmenu to display a vertical-style list and another one for changing offsets and size..
the patches are available here ...
http://schiewek.net/fresch/dmenu-3.8-vlist.diff
http://schiewek.net/fresch/dmenu-3.8-vlist-size.diff
Added options:
vlist.diff
[-l <#items>] activates vertical list mode, window will be adjusted for displaying #items
[-c] displays a counter in vlist mode (hits on applied filter)
vlist-size.diff
[-r] align right
[-w <width>] window width
[-h <height>] window height. you can breath a wish here, but it gets recalculated internally ( simplified: #items = height / font.height )
[-bo <width>] border width
[-x <xoffset>] distance to left or right side of the screen, depends on [-r]
[-y <yoffset>] distance to top or bottom of the screen, depends on [-b]
some things you should know about the added options:
[-h] has higher priority then [-l]
[-bo],[-x] and [-y] can be mixed. e.g: -bo 5 -r -x 10 will display the window aligned to the right, with a 5px distance to the top and
5px + 10px to right side of the screen
and be careful with those width and offset options, use appropriate values.. no error checking is done here. you have been warned: if you give evil values to this patched version of dmenu, it may display nothing, just crash or burn your computer...
examples:
mpc play `mpc playlist | dmenu -p "Find:" -r -l 10 -w 400 -y 5 -x 5| cut -c 2- - | sed -r s/"\).*$"/""/`
this would pop up a 400px-wide dmenu-window on the right side of the screen, with space for 10 items. distance to the right side and the top of the screen would be 5px.
mpc play `mpc playlist | dmenu -p "Find:" -h 150 -w 300 -bo 5| cut -c 2- - | sed -r s/"\).*$"/""/`
the window would show up in the top/left corner of the screen, with a 5px distance to the top and the left side,
height would be somewhere around 150px, width 300px.
I'll let the developer/s on http://www.mail-archive.com/dwm@suckless.org/ know about that.. stay tuned and have fun
suggestions and comments are welcome
fresch
Offline
Wow this looks awesome. I will try it tomorrow evening.
Offline
This is actually pretty nice. The only thing I'd like to see if I can add is changing the window size per # of matches, with a defined maximum size.
archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson
Offline
Works great. Looks great. Needs to be in the official release.
The ^ and v lines are redundant, I think.
It works nice as an OSD too now. xcowsay was so slow.
Offline
This is actually pretty nice. The only thing I'd like to see if I can add is changing the window size per # of matches, with a defined maximum size.
I'll include this option and update the patches for dmenu 3.9.
The ^ and v lines are redundant, I think.
... you don't want to know that there are actually more items on the list than displayed?
Well, those indicators may be redundant when the counter is enabled?!
thanks so far
fresch
Offline
I'll include this option and update the patches for dmenu 3.9.
Sweeeet. saves me the time.
archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson
Offline
http://schiewek.net/fresch/dmenu-3.9-fresch.diff
I removed the [-bo] option. The offset and size options should be enough..
but there are some new options, too
[-ms] multi-select; changes standard-behavior: selecting an item and pressing return won't close dmenu,
but leave you the opportunity to select some more items
[-nl] seperates standard output by newlines. could come in handy when using [-ms]
[-rs] resize; adjust window-size to display the matching items. [-l] defines the max.
[-ml] mark last item
[-lb] bg-color of last item
[-lf] fg-color of last item
some usage example: it now works more like a "real" playlist
mpc playlist | dmenu -i -nb "#000" -nf "#7af" -sb "#000" -sf "#bdf" -lf "#fff" -lb "#000" -p "Find:" -l 20 -y 10 -x 10 -w 400 -nl -rs -ms -ml | mpcplay
// mpcplay
#include <stdio.h>
#include <ctype.h>
#include <unistd.h>
#include <sys/types.h>
#define MAX 6
int main(void)
{
char c, buf[MAX], *args[] = {"mpc", "play", buf, NULL};
unsigned int i = 0;;
while ((c = fgetc(stdin)) != EOF) {
if (isdigit(c))
buf[i+1>MAX?i:i++] = c;
else if (c == ')')
buf[i+1>MAX?i:i++] = '\0';
else if (c == '\n') {
i = 0;
if (!fork())
execv("/usr/bin/mpc", args);
}
}
return 0;
}
@rson451: is [-rs] what you had in mind?
Last edited by fresch (2008-09-15 16:34:07)
Offline
Exactly. Still taking suggestions? If so, possibly add options for center horizontally and possibly vertically (at least initially if -rs is specified). I'm thinking this would make a very nice suckless netcfg2 menu that could pop up right in the middle of the screen. If those aren't things you want to add I'll play with it.
archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson
Offline
You made a typo in your post:
[-cb] bg-color of last item
[-cf] fg-color of last item
are options -lb, -lf
But I don't notice any difference when using them with -ml.
Offline
hm, you are right, thanks
and suggestions are welcome.
@rson451 you can use the size and offset options to center the initial window... but the hole positioning/size thingy somehow sucks
But I don't notice any difference when using them with -ml.
tried using it with -ml and -ms? you wont see a differently colored item, if dmenu immediately closes after selecting one -> it just works in multi-select-mode
but its current behavior is definitely arguable ...
share some screenshots showing how you use it!
fresch
Offline
Offline
I delved in and did it myself.
http://paste.pocoo.org/show/Jt26enSz3uLBZ6Wsx75p/
Adds the option -osd, that will hide the ^ and v lines.
And here is the patch for fresch's .c file, because I am not good with C and patches, so you can spot dangerous things easier.
http://paste.pocoo.org/show/XDT38XdcbppD75T6Kmaq/
EDIT:
By the way, I just see it while looking over the patch, it only works for topbar. If you want I can update that.
And I forgot to copy the config.h stuff.
Here is the full patch then, everything at patch -p0 level
http://paste.pocoo.org/show/AhS00FV150xIoK46jFZZ/
EDIT:
I said it doesn't work for topbar, but I meant it only works for topbar.
Last edited by Procyon (2008-09-17 10:18:54)
Offline
I used fresch's 3.9 patch and made a package in the AUR: http://aur.archlinux.org/packages.php?ID=20063.
Offline
Unbelievably evil me took the liberty of modifying fresch's mpcplay to be a little bit more general so I can use a dmenu script similar to the ones above to add folders to the playlist.
Enjoy:
#! /bin/sh
exec mpc listall | \
grep -o '.*/'| \
awk '!x[$0]++' | \
dmenu -i -nb "#000" -nf "#7af" -sb "#000" -sf "#bdf" -lf "#fff" -lb "#000" -p "Find:" -l 20 -y 10 -x 10 -w 400 -nl -rs -ms -ml | \
mpcplay add
#include <stdio.h>
#include <ctype.h>
#include <unistd.h>
#include <sys/types.h>
#include <string.h>
static char buf[128];
int usage()
{
printf(
"Usage: mpcplay [command]\n"
" Reads lines from stdin and executes `mpc <command> <line>\n"
);
return 1;
}
int main(int argc, char **argv)
{
char c, *args[] = {"mpc", NULL, buf, NULL};
unsigned int i = 0;
/*
we're too nice... since it is now a more general tool, this part should be up to the
executing shell script or whatever...
*/
int digits_only;
if(argc < 2)
args[1] = "play";
else if(argc == 2)
args[1] = argv[1];
else
return usage();
digits_only = (strcmp(args[1], "play") == 0);
while ((c = fgetc(stdin)) != EOF) {
if(c != '\n')
{
if(!digits_only || isdigit(c))
buf[i+1>sizeof(buf)?i:i++] = c;
else if(c == ')')
buf[i+1>sizeof(buf)?i:i++] = '\0';
}
else
{
i = 0;
if (!fork())
execv("/usr/bin/mpc", args);
}
}
return 0;
}
You know you're paranoid when you start thinking random letters while typing a password.
A good post about vim
Python has no multithreading.
Offline
I delved in and did it myself.
I'll include your changes, but renaming -osd to something like -ri for "remove indicators"... if you don't mind. And I think it then should be available for standard dmenu, too.
I used fresch's 3.9 patch and made a package in the AUR: http://aur.archlinux.org/packages.php?ID=20063.
Thanks a lot! But now I/we should update the manpage, as well.
Unbelievably evil me took the liberty of modifying fresch's mpcplay to be a little bit more general so I can use a dmenu script similar to the ones above to add folders to the playlist.
fresch
Offline
Procyon wrote:I delved in and did it myself.
I'll include your changes, but renaming -osd to something like -ri for "remove indicators"... if you don't mind. And I think it then should be available for standard dmenu, too.
Great, thanks!
I took another peek at the code and experimented with topbar off, and unlike what I said it does seem to work.
One redundant change seems to be:
ry = topbar ? (displaymoreless ? y : 0) + yoffset : y - rmh + (dc.font.height + 2) - yoffset;
Just y + yoffset works the same, and that was the only time topbar seemed to make a difference on the changed code.
Offline
I just used the AUR version (v3.9) and installed etc, but now searching is case sensitive and it doesn't actually work.
I'm using this script and when I run it through the console I get this:
[anklyne@anklin ~]$ ~/mpc-dmenu
skipping: 1)
skipping: AC/DC
skipping: -
skipping: Highway
skipping: to
error parsing song numbers from: Hell
then it shows the status, like mpc does.
Now I'm no coding genius, but I'm guessing dmenu isn't outputting a song number like it probably should be.
Any body have any ideas as how to fix it?
Edit:
I fixed the case sensitive "problem". I just had to use the -i option for dmenu.
I still haven't got it changing songs yet though
Edit:
All fixed
Just had to remove the $ from this command:
sed -r s/"\).*$"/""/
Thanks for all your help my good men
Last edited by Anklyne (2008-10-03 16:12:52)
Offline
Maybe the script's author has a different version of dmenu or sed than you and I: dmenu removes the newline at the end of its output, and sed's "$" doesn't match when there is no newline, so it doesn't do anything. I edited the page on the mpd wiki. Just change the sed regexp from
s/"\).*$"/""/
to
s/"\).*"/""/
Edit: Beat! Hehe.
Last edited by peets (2008-10-03 16:14:59)
Offline
Maybe the script's author has a different version of dmenu or sed than you and I: dmenu removes the newline at the end of its output, and sed's "$" doesn't match when there is no newline, so it doesn't do anything. I edited the page on the mpd wiki. Just change the sed regexp from
s/"\).*$"/""/
to
s/"\).*"/""/
Edit: Beat! Hehe.
It worked perfectly fine before I changed to fresch's patched version, so it must've been dmenu.
Yeah, a little too late
Thanks anyway.
Last edited by Anklyne (2008-10-03 16:36:40)
Offline
It worked perfectly fine before I changed to fresch's patched version, so it must've been dmenu.
should be fixed with this one:
http://schiewek.net/fresch/dmenu-3.9-fresch-2.diff
this patch also adds the option to remove those unpopular ^v indicators.
And I edited the manpage: may anyone please have a look at this and let me know if the descriptions are ok?!
when this is done, I'm sure peets won't mind updating the package
Last edited by fresch (2008-10-04 01:08:35)
Offline
next one
http://schiewek.net/fresch/dmenu-3.9-fresch-3.diff
using -xs, the search now works like in the xmms playlist.
hope this one has fewer mistakes than the one from yesterday ;D someone should definitely review this.. at least to prove that the options do what the manpage promises
Offline
Just updated package. Please try and report any errors! fresch: I'll be reading the manpage soon.
Offline
I've found on the dwm mailing list a patch to add a history to dmenu. I've combine the original version with a correction to avoid a crash :
http://idomcfly.free.fr/patch/dmenu_history.diff
Offline
using -xs, the search now works like in the xmms playlist.
What does it mean?
Offline
I've found on the dwm mailing list a patch to add a history to dmenu. I've combine the original version with a correction to avoid a crash :
http://idomcfly.free.fr/patch/dmenu_history.diff
looks like it does something simliar to this:
cat histfile >> tmpfile && $cmd >> tmpfile && cat tmpfile | ./dmenu -nl >> histfile
I already thought about having something like a history or favorites for dmenu.. but I guess I will end up
programming my own mpd client
never used xmms, hm?
the filter is splitted into tokens using space as separator.
now dmenu will only show items that contain every token.
this is quite nice, when dmenu is used as a playlist for mpd. you can type the first few letters of the artists name followed by some letters of the song title, like: "ram she". and if you are a ramones fan, your dmenu will now probably show "Ramones - Sheena Is A Punk Rocker"
Offline