You are not logged in.

#1 2010-05-16 02:06:57

UQ-igor
Member
Registered: 2009-03-05
Posts: 42

Configuring dzen2 keyboard actions

Hi,

I'm trying to configure dzen to display my reminders on a certain key press, running under dwm.
So far I have:
(echo "Today's Tasks:"; rem) | dzen2 -e -l 7 -w 250 -h 14 -p -fn -*-fixed-*-*-*-*-9-*-*-*-*-*-*-* -x 880 -bg black -fg '#dddddd' &
Which puts a nice dzen bar over a part of the dwm status bar and on mouse-over it expands it to show my reminders.

Now, I would like to dzen to expand (uncollapse) only on a key press event, such as CTRL+>. So I started by trying to map togglecollapse action to only '>' key like this:

(echo "Today's Tasks:"; rem) | dzen2 -e 'onstart=grabkeys;key_leftanglebracket=togglecollapse;key_Escape=ungrabkeys,exit' -l 7 -w 250 -h 14 -p -fn -*-fixed-*-*-*-*-9-*-*-*-*-*-*-* -x 880 -bg black -fg '#dddddd' &

This however does not work. As soon as dzen starts it grabs the keyboard so that dwm and all other running apps do not respond. Pressing '>' does nothing while pressing Escape fortunately exits dzen and gives dwm keyboard control back.

So, I'm wondering is there is a way to get dzen to not grab keyboard control completely, but still be able to respond to certain key press events such as '>' or 'CTRL+>' ?

Thanks,
-Igs

Offline

#2 2010-05-16 08:53:38

gotmor
Member
From: Germany
Registered: 2007-09-03
Posts: 84
Website

Re: Configuring dzen2 keyboard actions

UQ-igor wrote:

Hi,

Now, I would like to dzen to expand (uncollapse) only on a key press event, such as CTRL+>. So I started by trying to map togglecollapse action to only '>' key like this:

(echo "Today's Tasks:"; rem) | dzen2 -e 'onstart=grabkeys;key_leftanglebracket=togglecollapse;key_Escape=ungrabkeys,exit' -l 7 -w 250 -h 14 -p -fn -*-fixed-*-*-*-*-9-*-*-*-*-*-*-* -x 880 -bg black -fg '#dddddd' &

This however does not work. As soon as dzen starts it grabs the keyboard so that dwm and all other running apps do not respond. Pressing '>' does nothing while pressing Escape fortunately exits dzen and gives dwm keyboard control back.

So, I'm wondering is there is a way to get dzen to not grab keyboard control completely, but still be able to respond to certain key press events such as '>' or 'CTRL+>' ?

The problem with your approach above is the "onstart=grabkeys" statement. This will grab the keyboard when dzen starts and obviosuly never release it due to a missing statement to do so.


There are 2 possible ways to do what you are looking for, though:

a)  Remove the above mentionted statement. This way dzen will (by default) only react to keyboard
     input when it has focus (mouse over). Of course you can bind any event to 'grabkeys'.

b)  If you want a 'global' keybinding that works regardless of current active focus configure your WM
     to send a respective command/signal to dzen.

     The eaisest way probably is to use something like this:
     

 -e '<your_custom_events>;sigusr1=togglecollapse'

and configure your WM to spawn:
     

 kill -SIGUSR1 `pidof dzen2`

on the desired key combo.

     Another possible approach is to echo '^collapse()/^uncollapse()/^togglecollapse()' to dzen.



HTH, Rob.

Offline

#3 2010-05-16 09:53:19

UQ-igor
Member
Registered: 2009-03-05
Posts: 42

Re: Configuring dzen2 keyboard actions

Hi Rob,

I tried your suggestion b) and it works. I've setup dzen as you described and then run kill -SIGUSR1 `pidof dzen2` from a shell and slave panel toggles as needed. The problem is it takes about a second for dzen to respond to the SIGUSR1 signal, which is very annoying. I guess I'll just stick with the simple collapse in mouseover for now.

Thanks for the suggestion, but it just seems like setting this up the way I imagined is more trouble than its worth!

-Igor

Offline

Board footer

Powered by FluxBB