[dev] dmenu idea and diff, Ability to set menu width

1 view
Skip to first unread message

Josh Hogan

unread,
Mar 4, 2012, 4:21:16 AM3/4/12
to d...@suckless.org
Hello,

I am not exactly sure how these get submitted to suckless but I have a small feature I coded that I'd like to be added to dmenu.

I made a patch that lets me set the menu width using a -w parameter.  When using this and the lines parameter you can have a bit more freedom in how the menu is presented.  

Patch is attached.  

Any feedback or comments are welcome, 

Thanks
Josh
dmenu-4.5-SetWidthOpt.diff

Martti Kühne

unread,
Mar 4, 2012, 4:59:00 AM3/4/12
to dev mail list
On Sun, Mar 04, 2012 at 01:21:16AM -0800, Josh Hogan wrote:
> Any feedback or comments are welcome,

Hi Josh

I think we all agree that we'd like to see patches in unified diff format at
least. Unified diff gives some (3 lines above and beneath) context as to where
to insert and remove code lines which are edited, since you also didn't specify
if you used the current stable version or mercurial tip, which would be
preferred.

cheers!
mar77i

Josh Hogan

unread,
Mar 7, 2012, 1:05:16 AM3/7/12
to d...@suckless.org, mysa...@gmail.com
Martti,

Thanks for the feedback on the diff format, I was using the normal old diff tool for the original diff file.  I created and attached a new one using hg diff  which looks like it would fit the format you mentioned.  The patch is built from the mercurial tip from about 2 days ago.

Thanks
~Josh
dmenu-4.5-SetWidthOpt.diff

Anselm R Garbe

unread,
Mar 17, 2012, 1:30:51 PM3/17/12
to dev mail list

I think this is only useful for the vertical dmenu mode. Wouldn't it
be more useful to determine the width dynamically instead for the
longest menu item in such a case? (Initially full screen width, but
once all input items have been processed a resize would do). Thus an
additional flage wouldn't be required either.

Cheers,
Anselm

Josh Hogan

unread,
Mar 17, 2012, 1:39:56 PM3/17/12
to dev mail list
This particular flag was built with vertical in mind. The only use in
Horizontal mode would be if there were parts of your status bar you didn't
want hidden (dmenu everything but the tray & clock for example).

While I like the idea of dynamic resizing in general It does cause some
inconsistent behaviors. You have a consistently shrinking menu as you type
that will grow again as you are making corrections and can be a bit
disorienting as you're typing. It also means that you will need to walk
through the entire result list every time you press a character to recalc
the width. Walking through the visible options could work but that means
that as you're scrolling through results your menu will keep resizing. Also
starting with full width means that as soon as you load up dmenu you are
welcomed with a large amount of your screen covered with non-useful
whitespace.

Anselm R Garbe

unread,
Mar 17, 2012, 1:45:10 PM3/17/12
to dev mail list
On 17 March 2012 18:39, Josh Hogan <jo...@sarafynn.org> wrote:
> This particular flag was built with vertical in mind.  The only use in
> Horizontal mode would be if there were parts of your status bar you didn't
> want hidden (dmenu everything but the tray & clock for example).

Ok

> While I like the idea of dynamic resizing in general It does cause some
> inconsistent behaviors.  You have a consistently shrinking menu as you type
> that will grow again as you are making corrections and can be a bit
> disorienting as you're typing.  It also means that you will need to walk
> through the entire result list every time you press a character to recalc
> the width.  Walking through the visible options could work but that means
> that as you're scrolling through results your menu will keep resizing.  Also
> starting with full width means that as soon as you load up dmenu you are
> welcomed with a large amount of your screen covered with non-useful
> whitespace.

I wasn't suggesting resizing it depending on the match, but resizing
it to the given font metrics for the longest item read from stdin
instead (only once at the start of dmenu).

Cheers,
Anselm

Bjartur Thorlacius

unread,
Mar 17, 2012, 3:28:00 PM3/17/12
to dev mail list
> I wasn't suggesting resizing it depending on the match, but resizing
> it to the given font metrics for the longest item read from stdin
> instead (only once at the start of dmenu).
>
Most simply, dmenu would be as wide as the screen.

Josh Hogan

unread,
Apr 19, 2012, 3:17:03 AM4/19/12
to d...@suckless.org
Updating on this.  I did some extra digging and it looks like the menu should be set to hold a max of 32 chars as that's the input limit.  I re-adjusted my patch and now it takes the font width * 32 and uses that as the width measurement.  With this I removed the custom size option and just allowed the caller to have it on or off by simply using a -w flag.  I've checked with both fixed and variable width fonts and it looks to operate correctly although it does give extra space with variable width fonts as I believe the reported width is for the widest character in the font.

diff attached.

> Date: Sat, 17 Mar 2012 19:28:00 +0000

> Subject: Re: [dev] dmenu idea and diff, Ability to set menu width
dmenu-4.5-SetWidthOpt.diff

Josh Hogan

unread,
Apr 29, 2012, 3:41:20 PM4/29/12
to d...@suckless.org
I know that there was some excitement about exposed password process monitoring when I sent my previous mail but I was curious if anyone had a chance to take a look at it.
dmenu-4.5-SetWidthOpt.diff
Reply all
Reply to author
Forward
0 new messages