# i3 config file (v4)
#
# Please see https://i3wm.org/docs/userguide.html for a complete reference!

# -------------------------
#  Variables
# -------------------------

set_from_resource $second_monitor i3wm.second_monitor HDMI-0

set $terminal alacritty
set $background_image ~/.local/share/wallpapers/current
set $screenshot_command ~/bin/scrot-clipboard

set $mod    Mod4
set $super  Shift

set $ws1 "1"
set $ws2 "2"
set $ws3 "3"
set $ws4 "4"
set $ws5 "5"
set $ws6 "6"
set $ws7 "7"
set $ws8 "8"
set $ws9 "9"

# -------------------------
#  Includes
# -------------------------

include colorscheme
include startup

# -------------------------
#  Keybinds
# -------------------------

# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod

# system

# reload the configuration file
bindsym $mod+c reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+$super+r restart
# exit i3 (logs you out of your X session)
bindsym $mod+$super+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"

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

# kill focused window
bindsym $mod+x kill

# start rofi
bindsym $mod+d exec "rofi -show drun"
bindsym $mod+p exec "rofi -show run"

# lock screen
bindsym $mod+$super+f exec "xautolock -locknow"

# take screenshot
bindsym $mod+s exec $screenshot_command

# Movement

# switch to workspace
bindsym $mod+1 workspace number $ws1
bindsym $mod+2 workspace number $ws2
bindsym $mod+3 workspace number $ws3
bindsym $mod+4 workspace number $ws4
bindsym $mod+5 workspace number $ws5
bindsym $mod+6 workspace number $ws6
bindsym $mod+7 workspace number $ws7
bindsym $mod+8 workspace number $ws8
bindsym $mod+9 workspace number $ws9

# move focused container to workspace
bindsym $mod+$super+1 move container to workspace number $ws1
bindsym $mod+$super+2 move container to workspace number $ws2
bindsym $mod+$super+3 move container to workspace number $ws3
bindsym $mod+$super+4 move container to workspace number $ws4
bindsym $mod+$super+5 move container to workspace number $ws5
bindsym $mod+$super+6 move container to workspace number $ws6
bindsym $mod+$super+7 move container to workspace number $ws7
bindsym $mod+$super+8 move container to workspace number $ws8
bindsym $mod+$super+9 move container to workspace number $ws9

# change focus
bindsym $mod+h focus left
bindsym $mod+j focus down
bindsym $mod+k focus up
bindsym $mod+l focus right

# alternatively, you can use the cursor keys:
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right

# move focused window
bindsym $mod+$super+h move left
bindsym $mod+$super+j move down
bindsym $mod+$super+k move up
bindsym $mod+$super+l move right

# alternatively, you can use the cursor keys:
bindsym $mod+$super+Left move left
bindsym $mod+$super+Down move down
bindsym $mod+$super+Up move up
bindsym $mod+$super+Right move right

# split in horizontal orientation
bindsym $mod+$super+v split h

# split in vertical orientation
bindsym $mod+v split v

# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle

# change container layout (stacked, tabbed, toggle split)
# bindsym $mod+s layout stacking
# bindsym $mod+w layout tabbed
# bindsym $mod+e layout toggle split

# toggle tiling / floating
bindsym $mod+$super+space floating toggle

# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle

# focus the parent container
bindsym $mod+a focus parent

# focus the child container
#bindsym $mod+d focus child

# resize window (you can also use the mouse for that)
mode "resize" {
    # These bindings trigger as soon as you enter the resize mode

    # Pressing left will shrink the window’s width.
    # Pressing right will grow the window’s width.
    # Pressing up will shrink the window’s height.
    # Pressing down will grow the window’s height.
    bindsym h resize shrink width 10 px
    bindsym j resize grow height 10 px
    bindsym k resize shrink height 10 px
    bindsym l resize grow width 10 px

    bindsym $super+h resize shrink width 25 px
    bindsym $super+j resize grow height 25 px
    bindsym $super+k resize shrink height 25 px
    bindsym $super+l resize grow width 25 px

    # same bindings, but for the arrow keys
    bindsym Left resize shrink width 10 px
    bindsym Down resize grow height 10 px
    bindsym Up resize shrink height 10 px
    bindsym Right resize grow width 10 px

    # back to normal: Enter or Escape or $mod+r
    bindsym Return mode "default"
    bindsym Escape mode "default"
    bindsym $mod+r mode "default"
}

bindsym $mod+r mode "resize"

# -------------------
# Workspace settings
# -------------------

workspace $ws1 output primary
workspace $ws2 output primary
workspace $ws3 output primary
workspace $ws4 output primary
workspace $ws5 output primary
workspace $ws6 output primary
workspace $ws7 output primary
workspace $ws8 output primary

#for second screen
workspace $ws9 output $second_monitor gaps inner 0
#workspace $ws9 output primary

# Assignments

assign [window_role="browser"] $ws2
assign [class="^Code$"] $ws3
assign [class="^Telegram"] $ws9

for_window [window_role="pop-up"]                       floating enable
for_window [window_role="bubble"]                       floating enable
for_window [window_role="task_dialog"]                  floating enable
for_window [window_role="Preferences"]                  floating enable
for_window [window_type="dialog"]                       floating enable
for_window [window_type="menu"]                         floating enable
for_window [class="nm-connection-editor"]               floating enable

