[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Issue with keybind in autostart file.



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

Attachment: pgpi6apJ8GbtP.pgp
Description: PGP signature