#
# SXHKD module with HerbstluftWM-specific commands
#
# Part of my dotfiles: https://git.sr.ht/~protesilaos/dotfiles
#
### Description
#
# Partial configuration file for the Simple X Hotkey Daemon.  Meant to
# work with `herbstclient`.  This is part of my dotfiles, which are
# managed with GNU Stow.  See https://git.sr.ht/~protesilaos/dotfiles

### Code

# Close currently focused window.  mod4+q closes the frame if no
# window is present.  With shift it closes the frame of the last
# window while it closes that.  With mod4+alt+q remove the frame and
# merge its windows with the closest neighbouring frame.
mod4 + {_, shift +, alt+} q
    herbstclient {close_or_remove,close_and_remove,remove}

#### Focus/swap windows/tags

# Focus in the given direction.  With Shift move the window in the given
# direction.
mod4 + {_, shift +, ctrl +} {h,j,k,l}
    herbstclient {focus,shift,resize} {left,down,up,right} {_,_,0.05}

# Same as above but with arrow keys.
mod4 + {_, shift +, ctrl +} {Left,Down,Up,Right}
    herbstclient {focus,shift,resize} {left,down,up,right} {_,_,0.05}

# Place a frame in the given direction.
mod4 + alt + {h,j,k,l}
    herbstclient split {left,bottom,top,right} 0.5

# Same as above but with arrow keys.
mod4 + alt + {Left,Down,Up,Right}
    herbstclient split {left,bottom,top,right} 0.5


mod4 + {_,shift +} {0-9}
    herbstclient {use_index,move_index} {0-9}

mod4 + {f,shift + space}
    herbstclient {fullscreen toggle,set_attr clients.focus.floating toggle}

# Alt + Tab (cycle all windows and frames in the current tag)
mod1 + {_, shift +} Tab
    herbstclient cycle_all {+1,-1}

# Alt + Backtick (cycle all windows in the current frame)
mod1 + {_, shift +} grave
    herbstclient cycle {+1,-1}

mod4  + {_, shift +} r
    herbstclient {rotate,mirror both}

mod4 + t
    herbstclient cycle_layout +1 vertical horizontal max

mod4 + {_,shift +} Tab
    herbstclient use_index {+,-}1 --skip-visible

# Adjust size of frame gaps using my script.  This script of mine
# cycles through values 0 and 30, meaning that if we keep increasing
# or decreasing past either of those limits, we move to the other end:
# 0 5 ... 30 0 5.
mod4 + bracket{left,right}
    herbstluftwm_adjust_gaps {-,+}5

# Like the above, but for border width.
mod4 + shift + bracket{left,right}
    herbstluftwm_adjust_borders {-,+}5
