dotfiles/herbstluftwm/fish_functions/group.fish

41 lines
1.1 KiB
Fish
Raw Normal View History

#!/usr/bin/env
import notify
import log
import set_default
alias hc=herbstclient
set -g tag_color "ff99cc"
function groups_reset
set -e hlwm_group_active
end
function group_switch
set -f current $hlwm_group_active
if not set -q hlwm_group_active
set -U hlwm_group_active 2
else if test $hlwm_group_active -eq $hlwm_group_count
set -U hlwm_group_active 1
else
set -U hlwm_group_active (math $hlwm_group_active + 1)
end
log -c $tag_color "group $current -> $hlwm_group_active"
group_set_keybinds
notify "Group $hlwm_group_active"
end
# group_set_keybinds sets the keybinds to the given tab group
function group_set_keybinds
set_default hlwm_mod Mod4
log "group_set_keybinds: $hlwm_group_active"
if not set -q hlwm_group_active;
set -U hlwm_group_active 1
end
set -l offset (math (math $hlwm_group_active-1) x $hlwm_tags_per_group)
for tag in (seq $hlwm_tags_per_group)
set -l actual_tag (math $tag + $offset)
hc keybind $hlwm_mod-$tag use_index (math $actual_tag-1)
hc keybind $hlwm_mod-Shift-$tag move_index (math $actual_tag-1)
end
end