#!/bin/bash
herbstclient keyunbind --all

# keybindings
Mod=Mod4
herbstclient keybind $Mod-Control-q quit
herbstclient keybind $Mod-Shift-q close
herbstclient keybind $Mod-Shift-r reload

# tags
TAG_NAMES=( {1..9} 0 )
TAG_KEYS=( {1..9} 0 )

herbstclient rename default "${TAG_NAMES[0]}" || true
for i in ${!TAG_NAMES[@]} ; do
    herbstclient add "${TAG_NAMES[$i]}"
    key="${TAG_KEYS[$i]}"
    if ! [ -z "$key" ] ; then
        herbstclient keybind "$Mod-$key" use_index "$i"
        herbstclient keybind "$Mod-Shift-$key" move_index "$i"
    fi
done

# cycle through tags
herbstclient keybind $Mod-period use_index +1 --skip-visible
herbstclient keybind $Mod-comma  use_index -1 --skip-visible
herbstclient keybind $Mod-Right use_index +1 --skip-visible
herbstclient keybind $Mod-Left  use_index -1 --skip-visible
herbstclient keybind $Mod-minus use_previous

# layouting
herbstclient keybind $Mod-r remove

herbstclient keybind $Mod-space cycle_layout 1

herbstclient keybind $Mod-e split explode

herbstclient keybind $Mod-u split vertical 0.5
herbstclient keybind $Mod-Shift-u split vertical 0.66

herbstclient keybind $Mod-o split horizontal 0.5
herbstclient keybind $Mod-Shift-o split horizontal 0.666

herbstclient keybind $Mod-s floating toggle
herbstclient keybind $Mod-f fullscreen toggle
herbstclient keybind $Mod-p pseudotile toggle

# resizing
RESIZESTEP=0.02
herbstclient keybind $Mod-Control-h resize left +$RESIZESTEP
herbstclient keybind $Mod-Control-j resize down +$RESIZESTEP
herbstclient keybind $Mod-Control-k resize up +$RESIZESTEP
herbstclient keybind $Mod-Control-l resize right +$RESIZESTEP

# mouse in floating mode
herbstclient mouseunbind --all
herbstclient mousebind $Mod-Button1 move
herbstclient mousebind $Mod-Button2 zoom
herbstclient mousebind $Mod-Button3 resize

# focus
herbstclient set focus_follows_mouse 1
herbstclient rule focus=on
herbstclient keybind $Mod-BackSpace   cycle_monitor
herbstclient keybind $Mod-Tab         cycle_all +1
herbstclient keybind $Mod-Shift-Tab   cycle_all -1
herbstclient keybind $Mod-c cycle
herbstclient keybind $Mod-h focus left
herbstclient keybind $Mod-j focus down
herbstclient keybind $Mod-k focus up
herbstclient keybind $Mod-l focus right
herbstclient keybind $Mod-i jumpto urgent
herbstclient keybind $Mod-Shift-h shift left
herbstclient keybind $Mod-Shift-j shift down
herbstclient keybind $Mod-Shift-k shift up
herbstclient keybind $Mod-Shift-l shift right

