#########################
# i3/sway common config #
#########################

### Variables
#
# Logo key. Use Mod1 for Alt.
set $mod Mod4
# Home row direction keys, like vim
set $left h
set $down j
set $up k
set $right l
# keycodes for number keys
set $key1 10
set $key2 11
set $key3 12
set $key4 13
set $key5 14
set $key6 15
set $key7 16
set $key8 17
set $key9 18
set $key0 19
# Workspaces names. Format: "index:name"
set $ws1  "1:mail"
set $ws2  "2:web"
set $ws3  "3:3"
set $ws4  "4:4"
set $ws5  "5:5"
set $ws6  "6:6"
set $ws7  "7:7"
set $ws8  "8:8"
set $ws9  "9:9"
set $ws10 "10:10"
# Your preferred terminal emulator
set $term kitty --single-instance

# Font for window titles and bar
font pango:Hack 8

# Remove borders
hide_edge_borders smart
# Remove window title
default_border pixel 1
# Default to vertical split (vim :sp)

# Base16 color config
include ./colorscheme
# Property Name         Border  BG      Text    Indicator Child Border
client.focused          $base05 $base0D $base00 $base0D $base0D
client.focused_inactive $base01 $base01 $base05 $base03 $base01
client.unfocused        $base01 $base00 $base05 $base01 $base01
client.urgent           $base08 $base08 $base00 $base08 $base08
client.placeholder      $base00 $base00 $base05 $base00 $base00
client.background       $base07

### Key bindings
#
# Basics:

    # exit i3/sway
    bindsym $mod+Shift+e exec $exit

    # lock session
    bindsym Ctrl+Mod1+l exec $lock

    # application launcher
    bindsym $mod+r exec $menu

    # start a terminal
    bindsym $mod+Return exec $term

    # call clipboard plumber
    bindsym $mod+v exec cliplumber

    # volume control
    bindsym XF86AudioRaiseVolume exec amixer -q set Master 1%+ unmute
    bindsym XF86AudioLowerVolume exec amixer -q set Master 1%- unmute
    bindsym XF86AudioMute exec amixer -q set Master toggle

    # reload the configuration file
    bindsym $mod+Shift+r reload

    # restart i3/sway inplace (preserves your layout/session)
    bindsym $mod+Shift+x restart

    # kill focused window
    bindsym $mod+Shift+c kill

    # mouse button for dragging.
    floating_modifier $mod normal

#
# Moving around:
#
    # Move your focus around
    bindsym $mod+$left focus left
    bindsym $mod+$down focus down
    bindsym $mod+$up focus up
    bindsym $mod+$right focus right
    # or use $mod+[up|down|left|right]
    bindsym $mod+Left focus left
    bindsym $mod+Down focus down
    bindsym $mod+Up focus up
    bindsym $mod+Right focus right

    # _move_ the focused window with the same, but add Shift
    bindsym $mod+Shift+$left move left
    bindsym $mod+Shift+$down move down
    bindsym $mod+Shift+$up move up
    bindsym $mod+Shift+$right move right
    # ditto, with arrow keys
    bindsym $mod+Shift+Left move left
    bindsym $mod+Shift+Down move down
    bindsym $mod+Shift+Up move up
    bindsym $mod+Shift+Right move right
#
# Workspaces:
#
    # switch to workspace
    bindcode $mod+$key1 workspace $ws1
    bindcode $mod+$key2 workspace $ws2
    bindcode $mod+$key3 workspace $ws3
    bindcode $mod+$key4 workspace $ws4
    bindcode $mod+$key5 workspace $ws5
    bindcode $mod+$key6 workspace $ws6
    bindcode $mod+$key7 workspace $ws7
    bindcode $mod+$key8 workspace $ws8
    bindcode $mod+$key9 workspace $ws9
    bindcode $mod+$key0 workspace $ws10
    # move focused container to workspace
    bindcode $mod+Shift+$key1 move container to workspace $ws1
    bindcode $mod+Shift+$key2 move container to workspace $ws2
    bindcode $mod+Shift+$key3 move container to workspace $ws3
    bindcode $mod+Shift+$key4 move container to workspace $ws4
    bindcode $mod+Shift+$key5 move container to workspace $ws5
    bindcode $mod+Shift+$key6 move container to workspace $ws6
    bindcode $mod+Shift+$key7 move container to workspace $ws7
    bindcode $mod+Shift+$key8 move container to workspace $ws8
    bindcode $mod+Shift+$key9 move container to workspace $ws9
    bindcode $mod+Shift+$key0 move container to workspace $ws10
    # Note: workspaces can have any name you want, not just numbers.
    # We just use 1-10 as the default.
#
# Layout stuff:
#
    # You can "split" the current object of your focus with
    # $mod+b or $mod+v, for horizontal and vertical splits
    # respectively.
    #bindsym $mod+b splith
    #bindsym $mod+v splitv
    bindsym $mod+shift+v splith
    bindsym $mod+ctrl+shift+v splitv

    # Switch the current container between different layout styles
    bindsym $mod+s layout stacking
    bindsym $mod+w layout tabbed
    bindsym $mod+e layout toggle split

    # Make the current focus fullscreen
    bindsym $mod+f fullscreen

    # Toggle the current focus between tiling and floating mode
    bindsym $mod+Shift+space floating toggle

    # Swap focus between the tiling area and the floating area
    bindsym $mod+space focus mode_toggle

    # move focus to the parent container
    bindsym $mod+a focus parent
#
# Scratchpad:
#
    # Sway has a "scratchpad", which is a bag of holding for windows.
    # You can send windows there and get them back later.

    # Move the currently focused window to the scratchpad
    #bindsym $mod+Shift+minus move scratchpad

    # Show the next scratchpad window or hide the focused scratchpad window.
    # If there are multiple scratchpad windows, this command cycles through them.
    #bindsym $mod+minus scratchpad show
#
# Resizing containers:
#
mode "resize" {
    bindsym $left resize shrink width 10px
    bindsym $down resize grow height 10px
    bindsym $up resize shrink height 10px
    bindsym $right resize grow width 10px
    # ditto, with arrow keys
    bindsym Left resize shrink width 10px
    bindsym Down resize grow height 10px
    bindsym Up resize shrink height 10px
    bindsym Right resize grow width 10px

    # return to default mode
    bindsym Return mode "default"
    bindsym Escape mode "default"
}
# Mnemonic: Dimension
bindsym $mod+d mode "resize"

# Fast resize
bindsym $mod+Ctrl+$left resize shrink width 5 px or 5 ppt
bindsym $mod+Ctrl+$down resize grow height 5 px or 5 ppt
bindsym $mod+Ctrl+$up resize shrink height 5 px or 5 ppt
bindsym $mod+Ctrl+$right resize grow width 5 px or 5 ppt

### Status Bar
#
# Read `man 5 sway-bar` for more information about this section.
bar {
    position top

    # When the status_command prints a new line to stdout, swaybar updates.
    # The default just shows the current date and time.
    #status_command while date +'%Y-%m-%d %l:%M:%S %p'; do sleep 1; done
    status_command i3status

    # Base16 colors for the statusbar
    colors {
        background $base00
        separator  $base04
        statusline $base05

        # State             Border  BG      Text
        focused_workspace   $base0D $base0D $base00
        active_workspace    $base03 $base03 $base00
        inactive_workspace  $base01 $base01 $base05
        urgent_workspace    $base0F $base0F $base00
        binding_mode        $base0A $base0A $base00
    }

    separator_symbol " | "
    strip_workspace_numbers yes
}