# __     ___    ____  ___    _    ____  _     _____ ____  
# \ \   / / \  |  _ \|_ _|  / \  | __ )| |   | ____/ ___| 
#  \ \ / / _ \ | |_) || |  / _ \ |  _ \| |   |  _| \___ \ 
#   \ V / ___ \|  _ < | | / ___ \| |_) | |___| |___ ___) |
#    \_/_/   \_\_| \_\___/_/   \_\____/|_____|_____|____/ 
#

set $mod Mod4
set $terminal alacritty

# Define variables for workspaces
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"
set $ws10 "10"

# Variables for movement keys
set $left "h"
set $right "l"
set $up "k"
set $down "j"

set $draw_wallpaper "feh --no-fehbg --bg-fill ~/Pictures/Wallpapers/2b.jpeg"



#   ____ _____ _   _ _____ ____      _    _     
#  / ___| ____| \ | | ____|  _ \    / \  | |    
# | |  _|  _| |  \| |  _| | |_) |  / _ \ | |    
# | |_| | |___| |\  | |___|  _ <  / ___ \| |___ 
#  \____|_____|_| \_|_____|_| \_\/_/   \_\_____|
#                                               
#  ____  _____ _____ _____ ___ _   _  ____ ____  
# / ___|| ____|_   _|_   _|_ _| \ | |/ ___/ ___| 
# \___ \|  _|   | |   | |  | ||  \| | |  _\___ \ 
#  ___) | |___  | |   | |  | || |\  | |_| |___) |
# |____/|_____| |_|   |_| |___|_| \_|\____|____/ 
#                                                

# Add gaps for windows
gaps inner 8
gaps outer 5
gaps top 50

default_border pixel
smart_borders on

# Remove focusing windows with mouse
focus_follows_mouse no

# Font i3 uses
font pango:monospace 8

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



#  ____ _____  _    ____ _____ _   _ ____       _    ____  ____  ____  
# / ___|_   _|/ \  |  _ \_   _| | | |  _ \     / \  |  _ \|  _ \/ ___| 
# \___ \ | | / _ \ | |_) || | | | | | |_) |   / _ \ | |_) | |_) \___ \ 
#  ___) || |/ ___ \|  _ < | | | |_| |  __/   / ___ \|  __/|  __/ ___) |
# |____/ |_/_/   \_\_| \_\|_|  \___/|_|     /_/   \_\_|   |_|   |____/ 
#                                                                     

# Autostart
exec_always --no-startup-id $draw_wallpaper
exec_always --no-startup-id $HOME/.config/polybar/launch.sh
exec_always --no-startup-id "setxkbmap -layout \"us,ru\" -option \"grp:win_space_toggle\""
exec_always --no-startup-id picom --config $HOME/.config/picom.conf
exec_always --no-startup-id dunst 

# Assign applications to workspaces
assign [class="firefox"] $ws1
assign [class="Steam"] $ws3
assign [class="Code"] $ws2

# Force these applications to be floating
for_window [class="Steam"] floating enable
for_window [class="mpv"] floating enable
for_window [class="mpv"] move absolute center
for_window [class="Yad"] floating enable
for_window [class="Yad"] move absolute center
for_window [class="MuPDF"] floating enable


#  _  _________   ______ ___ _   _ ____ ___ _   _  ____ ____  
# | |/ / ____\ \ / / __ )_ _| \ | |  _ \_ _| \ | |/ ___/ ___| 
# | ' /|  _|  \ V /|  _ \| ||  \| | | | | ||  \| | |  _\___ \ 
# | . \| |___  | | | |_) | || |\  | |_| | || |\  | |_| |___) |
# |_|\_\_____| |_| |____/___|_| \_|____/___|_| \_|\____|____/ 
#                                                            


# Use Super+Tab to cycle through workspaces
bindsym $mod+Tab workspace next
bindsym $mod+Shift+Tab workspace prev

# Bind media keys on a keyboard to control volume and playback
bindsym XF86AudioRaiseVolume exec --no-startup-id pamixer -i 2
bindsym XF86AudioLowerVolume exec --no-startup-id pamixer -d 2
bindsym XF86AudioMute exec --no-startup-id pamixer -t
bindsym XF86AudioPlay exec playerctl play-pause
bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous

# Bind Super+Home keys to take a screenshot
bindsym $mod+Home exec --no-startup-id screenshoter

# Mod4 + Return starts a terminal
bindsym $mod+Return exec $terminal

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

# Binding to start rofi (Mod4 + d)
bindsym $mod+d exec --no-startup-id rofi -show run

# change focus
bindsym $mod+$left focus left
bindsym $mod+$down focus down
bindsym $mod+$up focus up
bindsym $mod+$right 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+Shift+$left move left
bindsym $mod+Shift+$down move down
bindsym $mod+Shift+$up move up
bindsym $mod+Shift+$right move right

# alternatively, you can use the cursor 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

# split in horizontal orientation
bindsym $mod+g 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 between stacking/tabbed/split
bindsym $mod+x layout toggle

# Toggle window state between tiling and floating
bindsym $mod+z floating toggle

# 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
bindsym $mod+0 workspace number $ws10

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

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

# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r restart

# Open applications with keybindings
bindsym Mod1+r exec alacritty -e ranger
bindsym Mod1+f exec firefox
bindsym Mod1+s exec steam

# 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 $left resize shrink width 10 px or 10 ppt
        bindsym $up resize grow height 10 px or 10 ppt
        bindsym $down resize shrink height 10 px or 10 ppt
        bindsym $right resize grow width 10 px or 10 ppt

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

        # 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"

