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

Re: Multiple commands in binding and keychain



On Sat, Sep 22, 2012 at 01:54:42PM +0200, Thorsten Wißmann wrote:
> Some examples are:
>   - They also can be nested, but I couldn't find a useful example. You
>     can play with it by using the tab completion (the separators show
>     you in which chains you are).

This chain command automatically implements keychains! And its an
example how to nest the chain command:

#!/bin/bash
keys=( {1..9} 0 )
unbind=(  )
for k in "${keys[ _at_ ]}" Escape ; do
    unbind+=( , keyunbind "$k" )
done

herbstclient keybind Mod1-u chain \
    '->' keybind "${keys[0]}" chain "${unbind[ _at_ ]}" , use_index 0 \
    '->' keybind "${keys[1]}" chain "${unbind[ _at_ ]}" , use_index 1 \
    '->' keybind "${keys[2]}" chain "${unbind[ _at_ ]}" , use_index 2 \
    '->' keybind "${keys[3]}" chain "${unbind[ _at_ ]}" , use_index 3 \
    '->' keybind "${keys[4]}" chain "${unbind[ _at_ ]}" , use_index 4 \
    '->' keybind "${keys[5]}" chain "${unbind[ _at_ ]}" , use_index 5 \
    '->' keybind "${keys[6]}" chain "${unbind[ _at_ ]}" , use_index 6 \
    '->' keybind "${keys[7]}" chain "${unbind[ _at_ ]}" , use_index 7 \
    '->' keybind "${keys[8]}" chain "${unbind[ _at_ ]}" , use_index 8 \
    '->' keybind "${keys[9]}" chain "${unbind[ _at_ ]}" , use_index 9 \
    '->' keybind Escape       chain "${unbind[ _at_ ]}"

This adds 10 keychains to switch tags and one to "exit" this chain menu:

  Mod1-u 0      # switch to the first workspace
  Mod1-u Escape # don't do anything

You also can let hlwm notify you when entering that keychain. Therefor
add this to the above '->' chain:

    '->' spawn notify-send "Select a workspace number or press Escape" \

Note that you need bash to execute the above code, but bash only is needed
to write the above code more compact. Once bound these keychains you
don't need bash anymore because everything runs herbstluftwm internally.


Thorsten