Issue with keybind in autostart file.

Thorsten Wißmann edu at thorsten-wissmann.de
Sun Aug 10 15:58:50 CEST 2014


Hi Rob,

On Sun, Aug 10, 2014 at 11:27:15AM +0100, Rob Pinder wrote:
> Comparing the output of hc list_keybinds | grep dme there's a difference in results between
> the command run in my autostart and the command run in a terminal. First result is for the
> non-functioning autostart, second is for the working terminal command. Note the extra space
> added in the font declaration.
> 
> Mod4+d	spawn	dmenu_run	-q	-h	16	-fn	Ubuntu  Mono-10	-nb	black	-nf	white
> 
> Mod4+d	spawn	dmenu_run	-q	-h	16	-fn	Ubuntu Mono-10	-nb	black	-nf	white
> 
> [1] http://hastebin.com/pizobugebo.bash

The problem is the following in your autostart:

hc() {
    cmds="$cmds , $@"
}

So you're creating one large string which is tokenized (cut into pieces)
at the end:

herbstclient chain $cmds&

and your "extra space" actually isn't two spaces but one tab. The
solution is to let the arrays stay arrays (i.e. don't make strings out
of them). In autostart, this means:

Replace the hc-definition by:

hc() {
    cmd+=( , "$@" )
}

(i.e. cmd is an array of strings and not just a single string). Then
replace the "fireing" of the array by:

herbstclient chain "${cmd[@]}"

You should omit the "&" because it might be that the panel or loadstate
depend on settings you have in your autostart.

In general: only do that kind of collecting the hc-commands if you
really know what you are doing. (It's not recommended and personally I
don't do that).

Cheers,
Thorsten
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 213 bytes
Desc: not available
URL: <https://listi.jpberlin.de/pipermail/hlwm/attachments/20140810/70ed3531/attachment.sig>


More information about the hlwm mailing list