### Variables

# Main keys
set $mod Mod4
set $ctrl Control
set $alt Mod1

# Home row direction keys, like vim
set $left h
set $down j
set $up k
set $right l

# Your preferred terminal emulator
set $term alacritty

# Your preferred application launcher
set $menu rofi -show drun

# Screenshot utility
set $shot "/usr/share/sway/scripts/grimshot"

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

set $bg #000000
set $br #ffa759
set $brbug #FF0000
set $textColor #cbccc6


#   ____ _____ _   _ _____ ____      _    _     
#  / ___| ____| \ | | ____|  _ \    / \  | |    
# | |  _|  _| |  \| |  _| | |_) |  / _ \ | |    
# | |_| | |___| |\  | |___|  _ <  / ___ \| |___ 
#  \____|_____|_| \_|_____|_| \_\/_/   \_\_____|
#                                             
default_border pixel 2px
smart_borders on
focus_follows_mouse no
gaps inner 10
floating_modifier $mod normal
font FiraCode 10
xwayland enable

# class                 border  backgr. text    indicator child_border
client.focused          $br     $br     $textColor     $brbug       $br

# Keyboard layout
input * {
  xkb_layout "us,ru"
  xkb_options "grp:win_space_toggle"
}





#     _    ____  ____  _     ___ ____    _  _____ ___ ___  _   _ ____  
#    / \  |  _ \|  _ \| |   |_ _/ ___|  / \|_   _|_ _/ _ \| \ | / ___| 
#   / _ \ | |_) | |_) | |    | | |     / _ \ | |  | | | | |  \| \___ \ 
#  / ___ \|  __/|  __/| |___ | | |___ / ___ \| |  | | |_| | |\  |___) |
# /_/   \_\_|   |_|   |_____|___\____/_/   \_\_| |___\___/|_| \_|____/ 
#                                                                     
# Start applications with keybindings
bindsym $alt+f exec firefox-developer-edition
bindsym $alt+r exec alacritty -e lf
bindsym $alt+s exec steam

# Assign specific applications their workspaces
assign [class="firefox"] $ws1
assign [class="Steam"] $ws3

# Default settings for some applications
for_window [class="mpv"] floating enable
for_window [class="mpv"] move absolute center
for_window [class="MuPDF"] floating enable
for_window [app_id="pavucontrol"] floating enable
for_window [app_id="blueman-manager"] floating enable

for_window [title="Picture-in-Picture"] {
  sticky enable
  move position 78ppt 65ppt
}



#     _   _   _ _____ ___  ____ _____  _    ____ _____ 
#    / \ | | | |_   _/ _ \/ ___|_   _|/ \  |  _ \_   _|
#   / _ \| | | | | || | | \___ \ | | / _ \ | |_) || |  
#  / ___ \ |_| | | || |_| |___) || |/ ___ \|  _ < | |  
# /_/   \_\___/  |_| \___/|____/ |_/_/   \_\_| \_\|_|  
#
exec_always --no-startup-id xrdb -load $HOME/.Xresources
exec_always --no-startup-id $HOME/.config/waybar/launch.sh
exec_always --no-startup-id dunst
exec_always --no-startup-id $HOME/dotfiles/bin/set-wallpaper --restore



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

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

bindsym F8 exec pavucontrol

bindsym $mod+equal exec swaymsg 'gaps inner current plus 10'
bindsym $mod+minus exec swaymsg 'gaps inner current minus 10'

# Make screenshots
# Ctrl+1,2,3 - Save screenshot of screen, selected window, selected area
bindsym $ctrl+1 exec --no-startup-id $shot --notify save output "$HOME/Pictures/Screenshots/Screenshot_$(date +%s%3N).png"
bindsym $ctrl+2 exec --no-startup-id $shot --notify save window "$HOME/Pictures/Screenshots/Screenshot_$(date +%s%3N).png"
bindsym $ctrl+3 exec --no-startup-id $shot --notify save area "$HOME/Pictures/Screenshots/Screenshot_$(date +%s%3N).png"
# Ctrl+Shift+1,2,3 - Copy screenshot of screen, selected window, selected area
bindsym $ctrl+Shift+1 exec --no-startup-id $shot --notify copy output
bindsym $ctrl+Shift+2 exec --no-startup-id $shot --notify copy window
bindsym $ctrl+Shift+3 exec --no-startup-id $shot --notify copy area

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

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

# Run wlogout to quit
bindsym $mod+Shift+e exec --no-startup-id wlogout -b 4 -m 450 -c 30

# Start your launcher
bindsym $mod+d exec $menu

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

# Move focus between tiling and floating areas
bindsym $mod+m focus mode_toggle

# Move focus
bindsym $mod+$left focus left
bindsym $mod+$down focus down
bindsym $mod+$up focus up
bindsym $mod+$right focus right

# Move focused windows
bindsym $mod+Shift+$left move left
bindsym $mod+Shift+$down move down
bindsym $mod+Shift+$up move up
bindsym $mod+Shift+$right move right

# Cycle through workspaces
bindsym $mod+Tab workspace next
bindsym $mod+Shift+Tab workspace prev

# 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

# Change split mode
bindsym $mod+g splith
bindsym $mod+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

# Toggle between layout modes
bindsym $mod+x layout toggle

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

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

### Resize mode
mode "resize" {
    bindsym $left resize shrink width 100px
    bindsym $down resize shrink height 100px
    bindsym $up resize grow height 100px
    bindsym $right resize grow width 100px

    # Return to default mode
    bindsym Return mode "default"
    bindsym Escape mode "default"
}
bindsym $mod+r mode "resize"

include /etc/sway/config.d/*
