Configure dwm (Linux) to peek when MODKEY is held

1.3k views Asked by At

I just installed dwm on Arch and am loving it. However, I found that I have no use for the status bar except when I'm switching tags, so I thought a useful feature would be to only display it while MODKEY is pressed.

I know that MODKEY+b toggles the bar, but I'd like to be able to peek at it while MODKEY's being held down. I'd also prefer that this doesn't consume the event, so I'll still be able to chain additional keys onto the sequence.

The only thing I found online about this was a post from Lokichaos (https://warosu.org/g/thread/24122078):

I split the difference with "peek" behavior. When I hold down Mod4 (my main dwm modkey) it shows the bar (but does not reserve space for it). The bar also auto-shows when there is an urgent client waiting (so I can see the highlighted tag). [...]

Is there any way I could implement this with my config.h file, or would I need to get into the nitty-gritty dwm.c? Any ideas as to how this could be done in an organized fashion so that I could bind other actions to key presses and releases?

Thanks for your help!

--EDIT--

This patch allows you to listen to release events, (they even show you how to toggle the bar with pressing/releasing MODKEY+b), but I'm only able to listen to presses and releases on non-mod keys. Again, my goal is to have the bar display when I press MODKEY, and disappear again when I release it.

Here are the three things I've tried in config.h:

  type           modifier                       key   function         argument
{ KeyRelease,MODKEY,                       0,      togglebar,      {0} },
{ KeyRelease,MODKEY,                       NULL, togglebar,      {0} },
{ KeyRelease,MODKEY,                       XK_Super_L, togglebar,      {0} },

...to no avail.

1

There are 1 answers

0
Chinmay Chhajed On

You may try holdbar patch to serve your purpose. I am using this and it is working seamlessly without any errors.

Note that after using this, togglebar will not work any more and bar will be always hidden. Also you cannot map HOLDKEY to simply MODKEY as it takes keysym bindings. You can get them by running xev and pressing the required key. It's keysym value in hexadecimal will be displayed. I use the Super (Windows) key and it's keysym value is 0xffeb. I have applied the same patch. If you want to see, you can view it on Github.