diff --git a/herbstluftwm/.config/herbstluftwm/autostart b/herbstluftwm/.config/herbstluftwm/autostart index e79d3c9..f84b9a3 100755 --- a/herbstluftwm/.config/herbstluftwm/autostart +++ b/herbstluftwm/.config/herbstluftwm/autostart @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env zsh ## Helper functions: @@ -133,20 +133,24 @@ hc keybind $Mod-u jumpto urgent ## Tags: tag_names=( dev web {3..10} ) +tag_indexes=( {1..${#tag_names}} ) tag_keys=( bracketleft braceleft braceright parenleft equal asterisk parenright plus bracketright exclam ) -hc rename default "${tag_names[0]}" || true -for i in "${!tag_names[@]}"; do +hc rename default "${tag_names[1]}" || true +for i in $tag_indexes; do hc add "${tag_names[$i]}" key="${tag_keys[$i]}" if ! [ -z "$key" ] ; then + # ZSH array indexes start at 1, herbstluftwm tag indexes start + # at zero, so subtract one to match them. + j=$(( $i - 1 )) # first check if the tag is locked to some monitor. # if so, first focus the monitor hc keybind "$Mod-$key" chain \ - , silent substitute M tags."$i".my-monitor focus_monitor M \ - , use_index "$i" - hc keybind "$Mod-Shift-$key" move_index "$i" + , silent substitute M tags."$j".my-monitor focus_monitor M \ + , use_index "$j" + hc keybind "$Mod-Shift-$key" move_index "$j" fi done