# {{@@ header() @@}}
#  _____      ____ _ _   _
# / __\ \ /\ / / _` | | | |
# \__ \\ V  V / (_| | |_| |
# |___/ \_/\_/ \__,_|\__, |
#                    |___/

bindsym --to-code {

###############################################################
# Moving around
###############################################################

{%@@ for prefix in ["","$"] @@%}
    {%@@ for dir in "Left,Up,Right,Down".split(',') @@%}
        {%@@ set resize_cmd = "{} {} 20px".format(
            ('shrink' if (loop.index0 < 2) else 'grow'),
            ('height' if (loop.index0 % 2) else 'width'),
        ) @@%}
        {%@@ set d = "{}{}".format(prefix,dir) @@%}
        {#@@ Move focus @@#}
        $mod+{{@@ d @@}} focus {{@@ dir @@}}
        {#@@ Move window @@#}
        $mod+Shift+{{@@ d @@}} move {{@@ dir @@}}
        {#@@ Resize window @@#}
        $mod+Control+{{@@ d @@}} resize {{@@ resize_cmd @@}}
        {#@@ focus output @@#}
        $mod+mod1+{{@@ d @@}} focus output {{@@ dir @@}}
        {#@@ Move workspace to output @@#}
        $mod+mod1+Shift+{{@@ d @@}} move workspace output {{@@ dir @@}}
    {%@@ endfor @@%}
{%@@ endfor @@%}


###############################################################
# Workspaces
###############################################################

# Switch to workspace
# Move focused container to workspace
{%@@ for i in range(1,11) @@%}
    $mod+{{@@       i%10 @@}} workspace                {{@@ i @@}}
    $mod+Shift+{{@@ i%10 @@}} move container workspace {{@@ i @@}}
{%@@ endfor @@%}

# go/move to Workspaces
# button8,9 = Mouse next/prev button
# Prior,Next = PageUp/Down
{%@@ for targ, buttons in {
    "prev_on_output": [ key.tabL, "bracketleft", "Prior", "button9", "button4", ],
    "next_on_output": [ key.tabR, "bracketright", "Next", "button8", "button5", ],
}.items() @@%}
{%@@ for button in buttons @@%}
    {%@@ set pref = ("--whole-window " if "button" in button) @@%}
    {{@@ pref @@}}$mod+{{@@       button @@}}      workspace {{@@ targ @@}}
    {{@@ pref @@}}$mod+Shift+{{@@ button @@}} move workspace {{@@ targ @@}}
{%@@ endfor @@%}
{%@@ endfor @@%}

$mod+Tab       workspace next_on_output
$mod+Shift+Tab workspace prev_on_output


###############################################################
# Layout
###############################################################

# Splits
$mod+v splitv
# No splith since we can just mod+r

# Layout styles
$mod+t layout toggle split tabbed stacking
$mod+r layout toggle split

# Make the current focus fullscreen
$mod+f fullscreen

# Floating
$mod+Shift+space floating toggle
$mod+space focus mode_toggle

# Move focus to the parent container
$mod+equal focus parent
$mod+minus focus child

# $mod+tab scratchpad show
# $mod+Shift+tab move container scratchpad

}

# vim: ft=i3
