You are not logged in.

#26 2008-10-14 18:35:07

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: dmenu patch for adding a vertical list and chaning its size/offsets

A question for any/all of you dmenu hackers wink

I'm looking for a way to patch dmenu so that the window it creates is identified as "dock" type (I'm using it with compiz-fusion and compiz draws shadows around the window, which is annoying) -- is there a simple way to implement something like this?

Offline

#27 2008-10-15 00:26:15

fresch
Member
Registered: 2008-08-06
Posts: 17

Re: dmenu patch for adding a vertical list and chaning its size/offsets

you could try something like

#define <X11/Xatom.h>
Atom a = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_DOCK", false);
XChangeProperty (dpy, root, a, XA_ATOM, 32, PropModeReplace, (unsigned char *) &a, 1);

but I think it would be a misuse of _NET_WM_WINDOW_TYPEs

a better way, if compiz supports this (and i guess it does) would be:

Setting the WM_CLASS:

XClassHint *ch = XAllocClassHint();
ch->res_name = "dmenu";
ch->res_class = "dmenu";
XSetClassHint(dpy, win, ch);
XFree(ch);

or the WM_NAME:

XTextProperty name;
name.value = (unsigned char *) "dmenu";
name.encoding = XA_STRING;
name.format = 8;
name.nitems = strlen((char *) name.value);
XSetWMName(dpy, win, &name);

somewhere in setup() before the window is getting mapped
and then telling compiz not to draw shadows for windows with WM_NAME or WM_CLASS = dmenu

Last edited by fresch (2009-08-04 22:53:04)

Offline

#28 2008-10-15 01:18:50

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: dmenu patch for adding a vertical list and chaning its size/offsets

Thanks a lot fresch!  I used the WM_CLASS method and it works great!  Here is a patch, in case anyone else is interested:

--- dmenu-3.9/dmenu.c.orig    2008-10-14 21:01:38.000000000 -0400
+++ dmenu-3.9/dmenu.c    2008-10-14 21:06:26.000000000 -0400
@@ -649,6 +649,13 @@
     text[0] = 0;
     match(text);
     XMapRaised(dpy, win);
+
+  /* set WM_CLASS */
+  XClassHint *ch = XAllocClassHint();
+  ch->res_name = "dmenu";
+  ch->res_class = "dmenu";
+  XSetClassHint(dpy, win, ch);
+  XFree(ch);
 }
 
 int

Offline

#29 2009-05-13 22:57:26

zenix
Member
From: Earth - Save it!
Registered: 2007-08-05
Posts: 104
Website

Re: dmenu patch for adding a vertical list and chaning its size/offsets

Hey, sorry to revive an old topic, but I thought you all might appreciate it smile

I took the following patches:
* fresch's vertical patch
* fwojciec's WM_CLASS patch
* geob's history patch (linked to earlier)

And merged them together, to work in dmenu 4.0! (It was just released recently)

You can find the patch here: http://evaryont.me/dmenu-vertical-history.patch

Enjoy! All tests seem to point to it working pretty damn great. wink


I made an AUR helper once.
I also go by evaryont and nogweii elsewhere on the internet.
Check out my projects and packages.

Offline

#30 2009-05-14 19:31:39

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,000
Website

Re: dmenu patch for adding a vertical list and chaning its size/offsets

Wow. I never really checked this out because I didn't see the need, but now I did and i like it. (i installed the 3.9 package from aur)
I recently started working on a tool called awmenu (http://bbs.archlinux.org/viewtopic.php?id=71453) which is basically supposed to become the gtk equivalent of "dmenu -i -xs -rs -l 10", but also with copy paste support (eg the ability to paste into the search field) and a few small things (see below)
The xmms/awesomebar style matching is really sweet for so many use cases.
I'm actually considering dropping development on awmenu and using this.  Features i would like to see (and could contribute myself when I find the time) however:
1) pasting stuff from primary selection and clipboard into search buffer.
2) shortcuts to go to beginning/end of input buffer.
3) highlighting of matched portions of the string.
4) coloring specific input lines differently (by prefixing all lines on stdin with <#colorcode><space> or something)


PS: I suggest you send this upstream and ask if they can consider merging it.  Otherwise I suggest you fork it under an other name, so we can use both versions alongside each other.

Last edited by Dieter@be (2009-05-14 19:41:33)


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#31 2009-06-03 12:20:14

Meillo
Member
From: Balmora
Registered: 2009-05-21
Posts: 10
Website

Re: dmenu patch for adding a vertical list and chaning its size/offsets

I created a stripped-down version of fresch's patch (which matches dmenu's style much better :-) ).

The patch: http://prog.marmaro.de/dwm-meillo/dmenu … eillo.diff

My announcement on the mailing list: http://lists.suckless.org/dev/0906/0193.html


Finally, thanks go to Dennis Ritchie and Ken Thompson, who showed a generation of programmers that complexity is avoidable.
(Marc J. Rochkind in Advanced UNIX Programming)

Offline

#32 2009-07-09 13:19:43

fresch
Member
Registered: 2008-08-06
Posts: 17

Re: dmenu patch for adding a vertical list and chaning its size/offsets

I totally forgot about this..

there are some utf8/unicode issues that need to be resolved,... I recall there was a small patch somewhere in gentoo-land
and I have some ideas on how to integrate this history more nicely
and...  I probably will have a look at those things Dieter@be suggested

edit: and thanks to meillo, dieter@be and krayon for keeping this up... did I forget anyone?

Last edited by fresch (2009-07-09 13:30:51)

Offline

#33 2009-07-09 13:59:57

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: dmenu patch for adding a vertical list and chaning its size/offsets

C-V + Shift-Ins, arrow keys + C-A + C-E, and C-U + C-K would be really convenient.

Offline

#34 2009-07-10 17:55:37

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,000
Website

Re: dmenu patch for adding a vertical list and chaning its size/offsets

fresch wrote:

I totally forgot about this..

there are some utf8/unicode issues that need to be resolved,... I recall there was a small patch somewhere in gentoo-land
and I have some ideas on how to integrate this history more nicely
and...  I probably will have a look at those things Dieter@be suggested

edit: and thanks to meillo, dieter@be and krayon for keeping this up... did I forget anyone?

I am very happy to read that smile  Some people (incl me) use dmenu-vertical extensively with uzbl, so those extra features would be great


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#35 2009-07-22 16:25:12

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: dmenu patch for adding a vertical list and chaning its size/offsets

Do you think it is also possible to optionally change the search to match the first matched line instead of the best match?

For instance I have the following menu entries:

...
uzbl --uri "$(xsel -o)"
...
xsetroot ...
...

and when I type "xse" it selects xsetroot first. If you don't use it on dmenu_path then this is a bit counter intuitive.

Offline

#36 2009-07-25 02:06:31

jzxu
Member
Registered: 2008-06-23
Posts: 10

Re: dmenu patch for adding a vertical list and chaning its size/offsets

First of all, thanks for maintaining the patch. However it seems that the stripped down version of the vertical dmenu always spans the entire horizontal space of the screen, which looks rather ugly and takes up a lot of screen space. I think it would be worthwhile to add some code to allow you to specify the width of the menu, and also possibly which corner of the screen you want the menu to appear, rather than just top and bottom. It wouldn't be that much bloat, would it?

Offline

#37 2009-07-25 08:14:15

fresch
Member
Registered: 2008-08-06
Posts: 17

Re: dmenu patch for adding a vertical list and chaning its size/offsets

depends on the users perspective cool

Offline

#38 2009-07-25 08:42:06

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,000
Website

Re: dmenu patch for adding a vertical list and chaning its size/offsets

jzxu wrote:

First of all, thanks for maintaining the patch. However it seems that the stripped down version of the vertical dmenu always spans the entire horizontal space of the screen, which looks rather ugly and takes up a lot of screen space. I think it would be worthwhile to add some code to allow you to specify the width of the menu, and also possibly which corner of the screen you want the menu to appear, rather than just top and bottom. It wouldn't be that much bloat, would it?

Imho, when a dmenu appears on your screen it's always the thing you should take care of first anyway, so it's not like you need to see anything below it.
Are you sure you can't do this already? When i look at http://www.uzbl.org/wiki/per-instance-history for example, I see dmenu is invoked with -x, -y and -w arguments to control position and size.


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#39 2009-07-25 08:46:57

jzxu
Member
Registered: 2008-06-23
Posts: 10

Re: dmenu patch for adding a vertical list and chaning its size/offsets

Dieter@be wrote:

Imho, when a dmenu appears on your screen it's always the thing you should take care of first anyway, so it's not like you need to see anything below it.

Yeah, that's true.

Are you sure you can't do this already? When i look at http://www.uzbl.org/wiki/per-instance-history for example, I see dmenu is invoked with -x, -y and -w arguments to control position and size.

I think this is the older version, with more options. The dmenu-vertical package in AUR does not accept -x and -y arguments.

Offline

#40 2009-07-25 09:23:01

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,000
Website

Re: dmenu patch for adding a vertical list and chaning its size/offsets

Are you sure you can't do this already? When i look at http://www.uzbl.org/wiki/per-instance-history for example, I see dmenu is invoked with -x, -y and -w arguments to control position and size.

I think this is the older version, with more options. The dmenu-vertical package in AUR does not accept -x and -y arguments.

Seems like the package in AUR is broken because suddenly all the extra options (even the vertical stuff itself) are gone.
I guess as soon as that's fixed you'll get -x/y/w back so your problem will be solved.


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#41 2009-07-25 13:25:34

steve___
Member
Registered: 2008-02-24
Posts: 452

Re: dmenu patch for adding a vertical list and chaning its size/offsets

@dieter@be - Did you read post #31?  I haven't looked at the code but maybe those option were removed as part of Meillo paring down the code.

Offline

#42 2009-09-05 20:02:08

yasen
Member
From: Bulgaria
Registered: 2009-03-05
Posts: 39

Re: dmenu patch for adding a vertical list and chaning its size/offsets

You can safely ignore what I've written here - there's a better implementation of it on the first page, which I seem to have missed on my first pass through the topic.

Hi, I took the liberty of making a small dmenu fork, customizing dmenu for some of my usage cases.

There's the source:
http://omploader.org/vMmFoZg/dmenu-awesome.tar.gz

It compiles to dmenu-awesome, so you can use it alongside the original dmenu.

Changes:
* based off of dmenu 4.0 with vertical patch
* removed horizontal layout (always vertical, with default of 10 lines, the -l switch works)
* always case insensitive matching (removed -i option as it is on by default), no other matching mode
* alt+j, alt+k = next/previous item of the list, instead of next/previous "page"
* [main selling point] - "awesome bar" style matching, i.e. you can type 'test this' and the sentence 'this is a test' will get matched.

This is what Dieter was thinking of, I suppose. It's a very nice matching style.

I'm no C guy so the code is probably very hacky, but it gets the job done. If there's interest I could try adding paste support (copy is redundant, I think) to it, but I don't think it's that good of an idea.

Also a warning - with large datasets (~50 000 rows on my machine) it starts to get a little slow after the fourth or fifth word in the filter field.

Last edited by yasen (2009-09-05 20:54:01)

Offline

#43 2009-09-05 20:32:14

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,000
Website

Re: dmenu patch for adding a vertical list and chaning its size/offsets

yasen wrote:

Hi, I took the liberty of making a small dmenu fork, customizing dmenu for some of my usage cases.

There's the source:
http://omploader.org/vMmFoZg/dmenu-awesome.tar.gz

It compiles to dmenu-awesome, so you can use it alongside the original dmenu.

Changes:
* based off of dmenu 4.0 with vertical patch
* removed horizontal layout (always vertical, with default of 10 lines, the -l switch works)
* always case insensitive matching (removed -i option as it is on by default), no other matching mode
* alt+j, alt+k = next/previous item of the list, instead of next/previous "page"
* [main selling point] - "awesome bar" style matching, i.e. you can type 'test this' and the sentence 'this is a test' will get matched.

This is what Dieter was thinking of, I suppose. It's a very nice matching style.

I'm no C guy so the code is probably very hacky, but it gets the job done. If there's interest I could try adding paste support (copy is redundant, I think) to it, but I don't think it's that good of an idea.

Also a warning - with large datasets (~50 000 rows on my machine) it starts to get a little slow after the fourth or fifth word in the filter field.

actually fresch' patch already had the "awesome" matching style (it's the same as the xmms matching style).
I think the removal of some options like you did is not very good, but hey it's your fork...


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#44 2009-09-05 20:52:51

yasen
Member
From: Bulgaria
Registered: 2009-03-05
Posts: 39

Re: dmenu patch for adding a vertical list and chaning its size/offsets

Yes, I seem to have missed the last posts on the first page, as I just skimmed through it. His implementation is actually better smile Ignore my post.

Offline

#45 2009-09-12 21:37:59

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,000
Website

Re: dmenu patch for adding a vertical list and chaning its size/offsets

I just read the person who maintained the dmenu-vertical package switched to meillo's patch because some others gave 404's.
But he ran into problems with the patches so now the package is orphaned.

I think the 404's can be alleviated by downloading the patches and keeping them in the package source tree.  And it's too bad to see the package orphaned now...
Anyway I'm just trying the dmenu-vertical-xft package in AUR and this seems to work fine.  It looks like it has all the features that fresch created.

Fresch: any updates on "I probably will have a look at those things Dieter@be suggested" ? especially insert and shift-insert would be convenient smile


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#46 2009-09-19 11:17:19

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: dmenu patch for adding a vertical list and chaning its size/offsets

I think I got dmenu to behave a bit more sensibly with for instance:

echo $'a\nb\nbac\nba\n' | dmenu

Because of the preference to sort by full match, it will:
1. display the newline-only entry first
2. if you type ba, it will display ba before bac

I don't like this at all. I seem to get better results by changing on line 739: <-- (edit: that is with the patch applied... it is the first appenditem in the function match(char *pattern) right after if(append == 1))

appenditem(i, &lexact, &exactend);

To a duplicate of the next appenditem:

appenditem(i, &lprefix, &prefixend);

Last edited by Procyon (2009-09-19 11:19:00)

Offline

#47 2009-10-02 14:08:02

Scytale
Member
Registered: 2009-10-02
Posts: 1

Re: dmenu patch for adding a vertical list and chaning its size/offsets

Since we're patching and forking around on dmenu like crazy and I got a little confused, I have now started a real fork of dmenu and published it on GitHub. It tries to have clean feature branches to make it easy to keep track on the modifications.

The fork is called fmenu (for "fast", but also "forked" and "features"), is based on dmenu 4.0 and currently includes the vertical patch by meillo only. I will add more modifications if I think they're useful, or if the community thinks they are. If you want to have feature X, tell me. If you have a patch against the current "master" branch, even better. If you converted an existing dmenu patch to fmenu, please point me to the original patch to credit the author.

Offline

#48 2009-12-06 21:49:15

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: dmenu patch for adding a vertical list and chaning its size/offsets

4.2 is now out http://hg.suckless.org/dmenu/

I don't get the cursor patch. Vertical doesn't scroll as nice, has no indicators and uses the -l argument +4 or something. Paste patch uses sselp but everyone has their own program they use which shouldn't be too hard to make it be changeable on the command line (why is suckless starting to try to force their own products?), it works with unicode, so that's nice.

xmms search is missing.


So, I added the paste patch to 3.9.3 with all the other goodies from this thread

Here is what I noticed/added to the function kpress. I just used my own preference for x selection, I can't be bothered making a command line checker. (and you're changing the source anyway)

    if(IsFunctionKey(ksym) || IsKeypadKey(ksym)
       || IsMiscFunctionKey(ksym) || IsPFKey(ksym)
       || IsPrivateKeypadKey(ksym))
        return;

This will mess up Insert. Comment/remove it, not sure which one does insert specifically, but I don't notice any weird behavior from removing all.

Then to the first e->state check of ControlMask, I added at the end (for Control-V/clipboard)

        case XK_v:
            {
            FILE *fp;
            char *c;
            if(!(fp = (FILE*)popen("xsel -b", "r")))
                eprint("dmenu: Could not popen xsel\n");
            c = fgets(text + len, sizeof(text) - len, fp);
            pclose(fp);
            if(c == NULL)
                return;
            }
            len = strlen(text);
            if(len && text[len-1] == '\n')
                text[--len] = '\0';
            match(text);
            drawmenu();
            return;

On top level of that function I added (for Shift+Insert/X selection)

    if(CLEANMASK(e->state) & ShiftMask && ksym == XK_Insert) {
                FILE *fp;
                char *c;
                if(!(fp = (FILE*)popen("xsel", "r")))
                    eprint("dmenu: Could not popen xsel\n");
                c = fgets(text + len, sizeof(text) - len, fp);
                pclose(fp);
                if(c == NULL)
                    return;
            len = strlen(text);
            if(len && text[len-1] == '\n')
                text[--len] = '\0';
            match(text);
            drawmenu();
            return;
    }

Not really sure how switch/case works since I don't do C, but it allowed me to remove those sole { } here...

Offline

#49 2009-12-08 20:24:48

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,000
Website

Re: dmenu patch for adding a vertical list and chaning its size/offsets

Procyon wrote:

Why is there no mention of 4.2 there or on the front page....


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#50 2009-12-08 21:00:12

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: dmenu patch for adding a vertical list and chaning its size/offsets

Dieter@be wrote:
Procyon wrote:

Why is there no mention of 4.2 there or on the front page....

Yes it's actually pre-4.1, but don't let that stop you from reading the rest of my post.

Offline

Board footer

Powered by FluxBB